Skip to contentSkip to conversation

Memory-leak in nft

DISCUSSION Piyush Pangtey 1 participant 1 message Mar 15, 2016 netfilter

lore
Share & tools
lore
#0 lore raw

There is still some memory-leak in nft which is due to no matching free for xstrdup in scanner.l:580.
In main.c, argv is passed as a const, and in main.c:270 filename points to this const location (by optarg).
So it would be safe to remove xstrdup from scanner.l:580.

$ sudo valgrind --leak-check=full nft -f ~/backup.nft

==4075== 22 bytes in 1 blocks are definitely lost in loss record 1 of 3
==4075== at 0x4C2AB80: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)

==4075==    by 0x57A3839: strdup (strdup.c:42)
==4075==    by 0x41C0BD: xstrdup (utils.c:64)
==4075==    by 0x41EFA1: scanner_push_file (scanner.l:581)
==4075==    by 0x426C88: scanner_read_file (scanner.l:601)
==4075==    by 0x406225: main (main.c:347)

==4075==
==4075== LEAK SUMMARY:
==4075== definitely lost: 22 bytes in 1 blocks
==4075== indirectly lost: 0 bytes in 0 blocks
==4075== possibly lost: 0 bytes in 0 blocks
==4075== still reachable: 832 bytes in 2 blocks
==4075== suppressed: 0 bytes in 0 blocks

Signature · 2 lines
With regards,
Piyush Pangtey <[email protected]>