From: Mark Andrews Date: Wed, 5 Feb 2020 05:45:59 +0000 (+1100) Subject: 'lcfg' must be non NULL, remove test. X-Git-Tag: v9.16.0~29^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ba1af0280b90d3faa25da50910bc78e667844a3;p=thirdparty%2Fbind9.git '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); --- diff --git a/lib/isc/log.c b/lib/isc/log.c index 65c56774a89..1b196052269 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); }