]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
source-nflog: fix memleaks
authorGiuseppe Longo <giuseppe@glongo.it>
Sun, 31 Mar 2019 12:00:00 +0000 (14:00 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 3 Apr 2019 18:35:17 +0000 (20:35 +0200)
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

index 90cbe4ddfba1a57bc26cb44691137226fc9717b0..38ddd309024155c0604844742c69727012e8d645 100644 (file)
@@ -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);
 }