EDN Admin
Well-known member
Hi,
when I run this code with an attached MS Application Verifier 4.0 an error is generated at the time of free():
<div style="color:Black;background-color:White; <pre>
#include <span style="color:#A31515; "stdafx.h"
#include <malloc.h>
<span style="color:Blue; int _tmain(<span style="color:Blue; int argc, _TCHAR* argv[])
{
{
<span style="color:Blue; void* pbyData = malloc(500000);
<span style="color:Green; //...
<span style="color:Blue; void* pbyCheck = _expand(pbyData, 190000);
<span style="color:Blue; if(pbyData != pbyCheck)
<span style="color:Blue; return <span style="color:Blue; false;
<span style="color:Green; //...
free(pbyData);
<span style="color:Blue; return <span style="color:Blue; true;
}
}
[/code]
<br/>
<div style="color:Black;background-color:White; <pre>
=======================================
VERIFIER STOP 0000000D: pid 0x17CC: Heap block corrupted after being freed.
06AF1000 : Heap handle <span style="color:Blue; for the heap owning the block.
06C08EB8 : Heap block that is corrupted.
0002E654 : Size of the block or zero <span style="color:Blue; if size cannot be determined.
06C08EA4 : Not used.
=======================================
This verifier stop is not continuable. Process will be terminated
when you use the `go debugger command.
=======================================
[/code]
<br/>
Does the _expand() really corrupt the heap?
What am I doing wrong?
Regards,
Martin
View the full article
when I run this code with an attached MS Application Verifier 4.0 an error is generated at the time of free():
<div style="color:Black;background-color:White; <pre>
#include <span style="color:#A31515; "stdafx.h"
#include <malloc.h>
<span style="color:Blue; int _tmain(<span style="color:Blue; int argc, _TCHAR* argv[])
{
{
<span style="color:Blue; void* pbyData = malloc(500000);
<span style="color:Green; //...
<span style="color:Blue; void* pbyCheck = _expand(pbyData, 190000);
<span style="color:Blue; if(pbyData != pbyCheck)
<span style="color:Blue; return <span style="color:Blue; false;
<span style="color:Green; //...
free(pbyData);
<span style="color:Blue; return <span style="color:Blue; true;
}
}
[/code]
<br/>
<div style="color:Black;background-color:White; <pre>
=======================================
VERIFIER STOP 0000000D: pid 0x17CC: Heap block corrupted after being freed.
06AF1000 : Heap handle <span style="color:Blue; for the heap owning the block.
06C08EB8 : Heap block that is corrupted.
0002E654 : Size of the block or zero <span style="color:Blue; if size cannot be determined.
06C08EA4 : Not used.
=======================================
This verifier stop is not continuable. Process will be terminated
when you use the `go debugger command.
=======================================
[/code]
<br/>
Does the _expand() really corrupt the heap?
What am I doing wrong?
Regards,
Martin
View the full article