From: Eric Leblond Date: Thu, 6 Sep 2012 10:03:54 +0000 (+0200) Subject: tls: fix error handling X-Git-Tag: suricata-1.4beta1~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=01d3c14449f995164cfc94278c89dc8adbe9873c;p=thirdparty%2Fsuricata.git tls: fix error handling Handling of error case was correct as pointed out by Coverity 717439. --- diff --git a/src/log-tlslog.c b/src/log-tlslog.c index ed8aa32766..365c56a5c5 100644 --- a/src/log-tlslog.c +++ b/src/log-tlslog.c @@ -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)