]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
tls: fix error handling
authorEric Leblond <eric@regit.org>
Thu, 6 Sep 2012 10:03:54 +0000 (12:03 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 6 Sep 2012 11:40:46 +0000 (13:40 +0200)
Handling of error case was correct as pointed out by Coverity
717439.

src/log-tlslog.c

index ed8aa327663eccd99183e74c59a4865e825a69ce..365c56a5c509a2fbf867f9f458f00e00e137eb1a 100644 (file)
@@ -562,13 +562,12 @@ OutputCtx *LogTlsLogInitCtx(ConfNode *conf)
     }
 
     if (SCConfLogOpenGeneric(conf, file_ctx, DEFAULT_LOG_FILENAME) < 0) {
-        LogFileFreeCtx(file_ctx);
-        return NULL;
+        goto filectx_error;
     }
 
     LogTlsFileCtx *tlslog_ctx = SCCalloc(1, sizeof(LogTlsFileCtx));
     if (tlslog_ctx == NULL)
-        return NULL;
+        goto filectx_error;
     tlslog_ctx->file_ctx = file_ctx;
 
     const char *extended = ConfNodeLookupChildValue(conf, "extended");
@@ -582,13 +581,20 @@ OutputCtx *LogTlsLogInitCtx(ConfNode *conf)
 
     OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
     if (output_ctx == NULL)
-        return NULL;
+        goto tlslog_error;
     output_ctx->data = tlslog_ctx;
     output_ctx->DeInit = LogTlsLogDeInitCtx;
 
     SCLogDebug("TLS log output initialized");
 
     return output_ctx;
+
+tlslog_error:
+    if (tlslog_ctx != NULL)
+        SCFree(tlslog_ctx);
+filectx_error:
+    LogFileFreeCtx(file_ctx);
+    return NULL;
 }
 
 static void LogTlsLogDeInitCtx(OutputCtx *output_ctx)