]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
outputs: fix memleaks in the error paths reported by coverity
authorVictor Julien <victor@inliniac.net>
Tue, 23 Oct 2018 11:49:37 +0000 (13:49 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 1 Nov 2018 14:46:10 +0000 (15:46 +0100)
src/alert-syslog.c
src/alert-unified2-alert.c

index 51b78bf2412349b74d58f23592bf8f5893255d7a..d09dbefe2a8f5a840cc8b758a7a291068bb2db57 100644 (file)
@@ -125,7 +125,8 @@ static OutputCtx *AlertSyslogInitCtx(ConfNode *conf)
 
     OutputCtx *output_ctx = SCMalloc(sizeof(OutputCtx));
     if (unlikely(output_ctx == NULL)) {
-        SCLogDebug("AlertSyslogInitCtx: Could not create new OutputCtx");
+        SCLogDebug("could not create new OutputCtx");
+        LogFileFreeCtx(logfile_ctx);
         return NULL;
     }
     memset(output_ctx, 0x00, sizeof(OutputCtx));
index 3f79488005a0e21f5b74b88f1a7e716633ddf423..dd33c1d4e1855317103166892644fa973ee5b32f 100644 (file)
@@ -1222,15 +1222,14 @@ error:
 OutputCtx *Unified2AlertInitCtx(ConfNode *conf)
 {
     int ret = 0;
-    LogFileCtx* file_ctx = NULL;
     OutputCtx* output_ctx = NULL;
     HttpXFFCfg *xff_cfg = NULL;
     int nostamp = 0;
 
-    file_ctx = LogFileNewCtx();
+    LogFileCtx* file_ctx = LogFileNewCtx();
     if (file_ctx == NULL) {
         SCLogError(SC_ERR_UNIFIED2_ALERT_GENERIC, "Couldn't create new file_ctx");
-        goto error;
+        return NULL;
     }
 
     const char *filename = NULL;
@@ -1345,6 +1344,8 @@ OutputCtx *Unified2AlertInitCtx(ConfNode *conf)
     return output_ctx;
 
 error:
+    LogFileFreeCtx(file_ctx);
+
     if (xff_cfg != NULL) {
         SCFree(xff_cfg);
     }