The results for this last example follow. In this case, valgrind was invoked with the
detailed leak checking turned on:
# valgrind --leak-check=yes ./valgrind_3
This time an error is generated by the double free, and the leak summary reports that the
program failed to release 40 bytes of memory that it had previously allocated:
==16584== Invalid free() / delete / delete[]
==16584== at 0xD1693D: free (vg_replace_malloc.c:231)
==16584== by 0x80483C7: main (in valgrind_3)
==16584== by 0x126BBE: __libc_start_main (in /lib/libc-2.3.2.so)
==16584== by 0x80482EC: (within valgrind_3)
==16584== Address 0x47BC07C is 0 bytes inside a block of size 160 free'd
==16584== at 0xD1693D: free (vg_replace_malloc.c:231)
==16584== by 0x80483B9: main (in valgrind_3)
==16584== by 0x126BBE: __libc_start_main (in /lib/libc-2.3.2.so)
==16584== by 0x80482EC: (within valgrind_3)
==16584==
==16584== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
==16584== malloc/free: in use at exit: 40 bytes in 1 blocks.
==16584== malloc/free: 2 allocs, 2 frees, 200 bytes allocated.
==16584== For counts of detected errors, rerun with: -v
==16584== searching for pointers to 1 not-freed blocks.
==16584== checked 4664864 bytes.
Chapter 14: Advanced Reverse Engineering
347
PART IV
Gray Hat Hacking: The Ethical Hacker??™s Handbook
348
==16584==
==16584== 40 bytes in 1 blocks are definitely lost in loss record 1 of 1
==16584== at 0xD1668E: malloc (vg_replace_malloc.
Pages:
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626