]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
'lcfg' must be non NULL, remove test.
authorMark Andrews <marka@isc.org>
Wed, 5 Feb 2020 05:45:59 +0000 (16:45 +1100)
committerMark Andrews <marka@isc.org>
Wed, 5 Feb 2020 07:37:17 +0000 (18:37 +1100)
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

index 65c56774a895f1394062226fe79970822ba30618..1b196052269485e76808bc8d85cf0eb708cd3627 100644 (file)
@@ -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);
 }