From: Giuseppe Longo Date: Sun, 31 Mar 2019 12:00:00 +0000 (+0200) Subject: source-nflog: fix memleaks X-Git-Tag: suricata-5.0.0-beta1~86 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c97423adf178e58f2e2d508aa6f538f2eae36d7;p=thirdparty%2Fsuricata.git 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). --- diff --git a/src/source-nflog.c b/src/source-nflog.c index 90cbe4ddfb..38ddd30902 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); }