From 7ba1af0280b90d3faa25da50910bc78e667844a3 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 5 Feb 2020 16:45:59 +1100 Subject: [PATCH] 'lcfg' must be non NULL, remove test. 389 else CID 1452695 (#1 of 1): Dereference before null check (REVERSE_INULL) check_after_deref: Null-checking lcfg suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 390 if (lcfg != NULL) 391 isc_logconfig_destroy(&lcfg); --- lib/isc/log.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/lib/isc/log.c b/lib/isc/log.c index 65c56774a8..1b19605226 100644 --- a/lib/isc/log.c +++ b/lib/isc/log.c @@ -321,17 +321,15 @@ isc_logconfig_create(isc_log_t *lctx, isc_logconfig_t **lcfgp) { lcfg = isc_mem_get(lctx->mctx, sizeof(*lcfg)); - { - lcfg->lctx = lctx; - lcfg->channellists = NULL; - lcfg->channellist_count = 0; - lcfg->duplicate_interval = 0; - lcfg->highest_level = level; - lcfg->tag = NULL; - lcfg->dynamic = false; - ISC_LIST_INIT(lcfg->channels); - lcfg->magic = LCFG_MAGIC; - } + lcfg->lctx = lctx; + lcfg->channellists = NULL; + lcfg->channellist_count = 0; + lcfg->duplicate_interval = 0; + lcfg->highest_level = level; + lcfg->tag = NULL; + lcfg->dynamic = false; + ISC_LIST_INIT(lcfg->channels); + lcfg->magic = LCFG_MAGIC; /* * Create the default channels: @@ -377,18 +375,18 @@ isc_logconfig_create(isc_log_t *lctx, isc_logconfig_t **lcfgp) { ISC_LOG_PRINTTIME); } - if (result == ISC_R_SUCCESS) + if (result == ISC_R_SUCCESS) { result = isc_log_createchannel(lcfg, "null", ISC_LOG_TONULL, ISC_LOG_DYNAMIC, NULL, 0); + } - if (result == ISC_R_SUCCESS) + if (result == ISC_R_SUCCESS) { *lcfgp = lcfg; - - else - if (lcfg != NULL) - isc_logconfig_destroy(&lcfg); + } else { + isc_logconfig_destroy(&lcfg); + } return (result); }