]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
pcap-log: Don't leak memory in LZ4 error paths
authorMax Fillinger <maximilian.fillinger@fox-it.com>
Mon, 11 Mar 2019 09:51:00 +0000 (10:51 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 22 Mar 2019 12:08:03 +0000 (13:08 +0100)
src/log-pcap.c

index a31e786939165acf9698c62299839a7157acb07e..65b888f28b258699def0b29c0c17e0510232f0e4 100644 (file)
@@ -650,6 +650,8 @@ static PcapLogData *PcapLogDataCopy(const PcapLogData *pl)
         if (copy_comp->buffer == NULL) {
             SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s",
                     strerror(errno));
+            SCFree(copy->h);
+            SCFree(copy);
             return NULL;
         }
         copy_comp->pcap_buf = SCMalloc(copy_comp->pcap_buf_size);
@@ -657,6 +659,8 @@ static PcapLogData *PcapLogDataCopy(const PcapLogData *pl)
             SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s",
                     strerror(errno));
             SCFree(copy_comp->buffer);
+            SCFree(copy->h);
+            SCFree(copy);
             return NULL;
         }
         copy_comp->pcap_buf_wrapper = SCFmemopen(copy_comp->pcap_buf,
@@ -665,6 +669,8 @@ static PcapLogData *PcapLogDataCopy(const PcapLogData *pl)
             SCLogError(SC_ERR_FOPEN, "SCFmemopen failed: %s", strerror(errno));
             SCFree(copy_comp->buffer);
             SCFree(copy_comp->pcap_buf);
+            SCFree(copy->h);
+            SCFree(copy);
             return NULL;
         }
 
@@ -679,6 +685,8 @@ static PcapLogData *PcapLogDataCopy(const PcapLogData *pl)
             fclose(copy_comp->pcap_buf_wrapper);
             SCFree(copy_comp->buffer);
             SCFree(copy_comp->pcap_buf);
+            SCFree(copy->h);
+            SCFree(copy);
             return NULL;
         }