Heap corruption

Everything else that doesn't fall into one of the other PB categories.
Denis
Enthusiast
Enthusiast
Posts: 790
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Heap corruption

Post by Denis »

Many thanks to Fred/Freak to write this piece of code (i don't know how has written Procedure _TestHeaps(File$, Line)).
I get a big crash (it close Purebasic , sometimes i have a black screen etc.) with allocateMemory fonction, a wrinting error.

I read deeply the blog issue on heap corruption and step by step i found the problem wich it comes from ma bad coding way :cry:

The error is "AllocateMemory heap corrupted"

Just for explanation, i done this. I used a temporary pointer and an another pointer

Code: Select all

Protected *lpIR.IconResource_Groupe
Protected *lpIR_temp.IconImage
I assign the pointers like this :

Code: Select all

*lpIR = AllocateMemory(SizeOf(ICONRESOURCE) + ((*lpIcon\idCount-1)*SizeOf(ICONIMAGE)))
*lpIR_temp = @*lpIR\IconImages
After that, i get icons from exe file with API ressource and i write this

Code: Select all

*lpIR_temp\dwNumBytes = SizeofResource_(hLibrary, hIconInfo)
With your procedure, step by step, i foud that the last line cause the crash
I change SizeofResource_(hLibrary, hIconInfo) by value 100 and it's the same crash, so the problem comes with my pointer... and the way i use it
A+
Denis