From 1c97423adf178e58f2e2d508aa6f538f2eae36d7 Mon Sep 17 00:00:00 2001 From: Giuseppe Longo Date: Sun, 31 Mar 2019 14:00:00 +0200 Subject: [PATCH] source-nflog: fix memleaks This fixes two memleaks found with ASAN. Direct leak of 96 byte(s) in 1 object(s) allocated from: #0 0x7f59cf4a4d28 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1d28) #1 0xd7f92f in ReceiveNFLOGThreadInit /home/glongo/suricata/src/source-nflog.c:221 #2 0xe9c8eb in TmThreadsSlotPktAcqLoop /home/glongo/suricata/src/tm-threads.c:293 #3 0x7f59cd7aa4a3 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x74a3) Indirect leak of 70000 byte(s) in 1 object(s) allocated from: #0 0x7f59cf4a4d28 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1d28) #1 0xd814ea in ReceiveNFLOGThreadInit /home/glongo/suricata/src/source-nflog.c:324 #2 0xe9c8eb in TmThreadsSlotPktAcqLoop /home/glongo/suricata/src/tm-threads.c:293 #3 0x7f59cd7aa4a3 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x74a3) SUMMARY: AddressSanitizer: 70096 byte(s) leaked in 2 allocation(s). --- src/source-nflog.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/source-nflog.c b/src/source-nflog.c index 90cbe4ddfba1..38ddd3090241 100644 --- a/src/source-nflog.c +++ b/src/source-nflog.c @@ -368,6 +368,14 @@ TmEcode ReceiveNFLOGThreadDeinit(ThreadVars *tv, void *data) ntv->h = NULL; } + if (ntv->data != NULL) { + SCFree(ntv->data); + ntv->data = NULL; + } + ntv->datalen = 0; + + SCFree(ntv); + SCReturnInt(TM_ECODE_OK); }