]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
log: Coverity REVERSE_INULL warnings
authorJeff Lucovsky <jeff@lucovsky.org>
Tue, 21 Sep 2021 13:52:11 +0000 (09:52 -0400)
committerVictor Julien <vjulien@oisf.net>
Thu, 13 Jan 2022 07:28:13 +0000 (08:28 +0100)
This commit addresses Coverity reported "REVERSE_INULL" warnings.

Issue: 4699

src/output-json.c

index 04bd6ed159953d7cacb5c86b536c0a9e68ddd456..3ff8d1bb0e2a9dc0bc4bc0848833e4a080c91d04 100644 (file)
@@ -1099,8 +1099,7 @@ OutputInitResult OutputJsonInitCtx(ConfNode *conf)
     json_ctx->file_ctx = LogFileNewCtx();
     if (unlikely(json_ctx->file_ctx == NULL)) {
         SCLogDebug("AlertJsonInitCtx: Could not create new LogFileCtx");
-        SCFree(json_ctx);
-        return result;
+        goto error_exit;
     }
 
     if (sensor_name) {
@@ -1238,11 +1237,16 @@ OutputInitResult OutputJsonInitCtx(ConfNode *conf)
 
 error_exit:
     if (json_ctx->file_ctx) {
+        if (json_ctx->file_ctx->prefix) {
+            SCFree(json_ctx->file_ctx->prefix);
+        }
+        if (json_ctx->file_ctx->sensor_name) {
+            SCFree(json_ctx->file_ctx->sensor_name);
+        }
         LogFileFreeCtx(json_ctx->file_ctx);
     }
-    if (json_ctx) {
-        SCFree(json_ctx);
-    }
+    SCFree(json_ctx);
+
     if (output_ctx) {
         SCFree(output_ctx);
     }