From 39d6551437089a6c6f1fb3c1af75f8eea917aa66 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Tue, 23 Oct 2018 13:49:37 +0200 Subject: [PATCH] outputs: fix memleaks in the error paths reported by coverity --- src/alert-syslog.c | 3 ++- src/alert-unified2-alert.c | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/alert-syslog.c b/src/alert-syslog.c index 51b78bf241..d09dbefe2a 100644 --- a/src/alert-syslog.c +++ b/src/alert-syslog.c @@ -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)); diff --git a/src/alert-unified2-alert.c b/src/alert-unified2-alert.c index 3f79488005..dd33c1d4e1 100644 --- a/src/alert-unified2-alert.c +++ b/src/alert-unified2-alert.c @@ -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); } -- 2.47.2