vmg / sundown

Standards compliant, fast, secure markdown processing library in C
1.99k stars 385 forks source link

Fix memory leaks #6

Closed bnoordhuis closed 13 years ago

bnoordhuis commented 13 years ago

ups_markdown() and bufrelease() leak memory. To reproduce:

$ touch empty.md
$ LD_LIBRARY_PATH=$PWD valgrind -q --leak-check=full ./upskirt empty.md 
==2707== 40 bytes in 1 blocks are definitely lost in loss record 1 of 2
==2707==    at 0x4C274A8: malloc (vg_replace_malloc.c:236)
==2707==    by 0x4E357F5: bufnew (buffer.c:174)
==2707==    by 0x400F7D: main (upskirt.c:60)
==2707== 
==2707== 40 bytes in 1 blocks are definitely lost in loss record 2 of 2
==2707==    at 0x4C274A8: malloc (vg_replace_malloc.c:236)
==2707==    by 0x4E357F5: bufnew (buffer.c:174)
==2707==    by 0x4E341A4: ups_markdown (markdown.c:1951)
==2707==    by 0x400FCA: main (upskirt.c:66)
==2707==

bufreset() has the same bug that bufrelease() has. It's not used according to grep and ctags but I patched it just in case.