User forums > Help

Malloc() / Heap issue with debug build target

<< < (3/3)

BlueHazzard:

--- Quote ---That's an indication of memory corruption. It's quite easy to do with C using malloc etc. It just hides problems so easily. And the best part is that the actual problem may not even be in that part of the code.
--- End quote ---
Yes. this are very strong signs for this kind of error:

--- Quote ---- if I declare one additional local variable in the function that calls the failing ReadString() it works.
- but if, additionaly to the extra declaration, I initialize the nr_of_lflags var it crashes again.
--- End quote ---

Have you introduced an range check for the malloc size? I do not see how the crash source should be in malloc... One possibility would be that you kill your call stack and it only seems to be that the crash is in malloc...

Boy how i am happy that i can use smart pointers  :)

Marnix:
Well, I found the culprit. It was a malloc() with length 0 in a part of the code I recently added. It had nothing to do with Code::Blocks.

I donated USD 20 for the inconvenience caused.

Thanks everybody.

Navigation

[0] Message Index

[*] Previous page

Go to full version