From 22e89ec4a3554a66ecf8c38e5b6fcfc95d4107e9 Mon Sep 17 00:00:00 2001 From: Jeff Lucovsky Date: Tue, 21 Sep 2021 09:52:11 -0400 Subject: [PATCH] log: Coverity REVERSE_INULL warnings This commit addresses Coverity reported "REVERSE_INULL" warnings. Issue: 4699 --- src/output-json.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/output-json.c b/src/output-json.c index 04bd6ed159..3ff8d1bb0e 100644 --- a/src/output-json.c +++ b/src/output-json.c @@ -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); }