   malloc(): memory corruption
  Hi, I was working on a game I'm making last night and came across a strange bug after I made lots of small changes to the source code.Whenever I try to start a multiplayer or singleplayer game, the game crashes. I get this output:*** glibc detected *** ./habit: malloc(): memory corruption: 0x08260128 ***======= Backtrace: =========/lib/i686/cmov/libc.so.6[0xb7aaa006]/lib/i686/cmov/libc.so.6(__libc_malloc+0x8d)[0xb7aab95d]/lib/i686/cmov/libc.so.6(realloc+0x1e6)[0xb7aad4e6]./habit[0x806dc33]./habit[0x80714d2]./habit[0x80736db]./habit[0x806e1ea]./habit[0x8069c56]./habit[0x8075119]./habit[0x8060cac]./habit[0x804ced3]./habit(__gxx_personality_v0+0x3cf)[0x804af17]./habit[0x806633e]/lib/i686/cmov/libc.so.6(__libc_start_main+0xe0)[0xb7a54450]./habit(__gxx_personality_v0+0xc9)[0x804ac11]======= Memory map: ========08048000-0808b000 r-xp 00000000 08:02 1575  /home/foobar/proj/habitIV/habit0808b000-0808c000 rw-p 00042000 08:02 1575  /home/foobar/proj/habitIV/habit0808c000-0829d000 rw-p 0808c000 00:00 0[heap]b4800000-b4821000 rw-p b4800000 00:00 0 b4821000-b4900000 ---p b4821000 00:00 0 b4936000-b6153000 rw-p b4936000 00:00 0 b6153000-b6154000 ---p b6153000 00:00 0 b6154000-b6dd6000 rw-p b6154000 00:00 0 b6dd6000-b70d6000 rw-s 00000000 00:09 2752534    /SYSV00000000 (deleted)b70d6000-b70f6000 rw-s 00000000 00:09 2719748    /SYSV0056a4d6 (deleted)b70f6000-b7106000 rw-s 00000000 00:0d 7054  /dev/snd/pcmC0D0pb7106000-b710f000 r-xp 00000000 08:03 10622 /lib/i686/cmov/libnss_files-2.7.sob710f000-b7111000 rw-p 00008000 08:03 10622 /lib/i686/cmov/libnss_files-2.7.sob7111000-b7119000 r-xp 00000000 08:03 10624 /lib/i686/cmov/libnss_nis-2.7.sob7119000-b711b000 rw-p 00007000 08:03 10624 /lib/i686/cmov/libnss_nis-2.7.sob711b000-b712f000 r-xp 00000000 08:03 10619 /lib/i686/cmov/libnsl-2.7.sob712f000-b7131000 rw-p 00013000 08:03 10619 /lib/i686/cmov/libnsl-2.7.sob7131000-b7133000 rw-p b7131000 00:00 0 b7133000-b7134000 ---p b7133000 00:00 0 b7134000-b7934000 rw-p b7134000 00:00 0 b7934000-b79f5000 r-xp 00000000 08:03 10971 /usr/lib/libasound.so.2.0.0b79f5000-b79fa000 rw-p 000c0000 08:03 10971 /usr/lib/libasound.so.2.0.0b7a08000-b7a09000 rw-s 81000000 00:0d 7054  /dev/snd/pcmC0D0pb7a09000-b7a0a000 r--s 80000000 00:0d 7054  /dev/snd/pcmC0D0pb7a0a000-b7a0e000 r-xp 00000000 08:03 20994 /usr/lib/libXxf86dga.so.1.0.0b7a0e000-b7a0f000 rw-p 00004000 08:03 20994 /usr/lib/libXxf86dga.so.1.0.0b7a0f000-b7a16000 r-xp 00000000 08:03 10620 /lib/i686/cmov/libnss_compat-2.7.sob7a16000-b7a18000 rw-p 00006000 08:03 10620 /lib/i686/cmov/libnss_compat-2.7.sob7a18000-b7a19000 r-xp 00000000 08:03 57792 /usr/lib/allegro/4.2.2/alleg-alsamidi.sob7a19000-b7a1a000 rw-p 00001000 08:03 57792 /usr/lib/allegro/4.2.2/alleg-alsamidi.sob7a1a000-b7a1e000 r-xp 00000000 08:03 57791 /usr/lib/allegro/4.2.2/alleg-alsadigi.sob7a1e000-b7a1f000 rw-p 00003000 08:03 57791 /usr/lib/allegro/4.2.2/alleg-alsadigi.sob7a1f000-b7a24000 r-xp 00000000 08:03 57790 /usr/lib/allegro/4.2.2/alleg-dga2.sob7a24000-b7a25000 rw-p 00004000 08:03 57790 /usr/lib/allegro/4.2.2/alleg-dga2.sob7a25000-b7a28000 rw-p b7a25000 00:00 0 b7a28000-b7a2c000 r-xp 00000000 08:03 18261 /usr/lib/libXdmcp.so.6.0.0b7a2c000-b7a2d000 rw-p 00003000 08:03 18261 /usr/lib/libXdmcp.so.6.0.0b7a2d000-b7a2f000 r-xp 00000000 08:03 18247 /usr/lib/libXau.so.6.0.0b7a2f000-b7a30000 rw-p 00001000 08:03 18247 /usr/lib/libXau.so.6.0.0b7a30000-b7a34000 r-xp 00000000 08:03 18528 /usr/lib/libXfixes.so.3.1.0b7a34000-b7a35000 rw-p 00003000 08:03 18528 /usr/lib/libXfixes.so.3.1.0b7a35000-b7a3c000 r-xp 00000000 08:03 20739 /usr/lib/libXrender.so.1.3.0b7a3c000-b7a3d000 rw-p 00007000 08:03 20739 /usr/lib/libXrender.so.1.3.0b7a3d000-b7a3e000 rw-p b7a3d000 00:00 0 b7a3e000-b7b85000 r-xp 00000000 08:03 10613 /lib/i686/cmov/libc-2.7.sob7b85000-b7b86000 r--p 00147000 08:03 10613 /lib/i686/cmov/libc???I get the same output when I run it in a debugger (gdb). Does anyone know what causes this type of error? I would be REALLY happy if someone could help me out, because right now my program is completely broken because of this stupid issue.Thanks!(If it matters, I am using Linux)   
  That error message means that you have memory corruption affecting the heap data structures. Likely causes are buffer overruns, using a freed pointer, incorrectly pairing new[]/delete or new/delete[], not using a virtual destructor for a base class and so on.   ;  By placing cout's at different places in my code, I have narrowed down the line that causes the issue. It's the line for loading the Lua script for the map being loaded, which doesn't make any sense.Would this type of crash be something that happens when the program hits a certain line (like a segfault does), or is it like a memory leak where the problem builds and then eventually surfaces?   ;  That's probably not the line that causes the issues, it's the line where the issue is detected. You probably corrupted the heap sometime before that line, and that line is the first time a heap consistency check was performed since the actual problem.   