views:

159

answers:

1

I'm wondering why randomly after executing the ./a.out I get the following. Any ideas what I'm doing wrong? Thanks

http://img710.imageshack.us/img710/8708/trasht.png

http://img710.imageshack.us/img710/8708/trasht.png

+2  A: 

As the error suggests you probably have a double free() or heap corruption

Edit: Either you're freeing the same buffer more than once or you're writing bytes in a memory region you shouldn't be writing to. The latter might be caused by writing in the buffer after freeing it or writing outside the buffer bounds.

Perhaps Memcheck can help pinpoint the problem.

Compile your program with debug information cc -g and run valgrind ./a.out

Alexandre Jasmin
so basically is because I'm freeing more times that I supposed to?
Mike
yes, you are. :)
vladr
It is also possible that you are writing to memory that you are not supposed to be writing to.
Gabe