Im developing a game using SFML+Box2D and got a heap corruption when I delete a Controller object, it triggers a breakpoint on
retval = HeapFree(_crtheap, 0, pBlock);
if (retval == 0)
{
errno = _get_errno_from_oserr(GetLastError());
}
On debug it says its a heap corruption and tells me "Unhandled exception at 0x771CE753 (ntdll.dll) in Alumni.exe: 0xC0000374: A heap has been corrupted (parameters: 0x77204270)."
How do I know what has been previously written on this memory adress? What are good pratices to avoid heap corruption? I was careful with my pointers, Im not double deleting anything.
If anyone wanna take the time, the repository is at github.com/mrseth/Alumni. You can trigger the crash pressing enter once and backspace. Enter spawns a Controller, backspace deletes the last spawned one. The code that deletes the controller is at https://github.com/mrseth/Alumni/blob/Stephen/Alumni/Alumni/TestClickListener.cpp