From a038f77d92a857bc11750683c9317d70da6fcfdf Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 5 Feb 2020 15:41:26 +1100 Subject: [PATCH 01/19] 'buffer' must be non-NULL as isc_buffer_allocate can no longer fail. 1636 cleanup: CID 1458130 (#1 of 1): Dereference before null check (REVERSE_INULL) check_after_deref: Null-checking buffer suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 1637 if (buffer != NULL) 1638 isc_buffer_free(&buffer); --- lib/dns/catz.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/dns/catz.c b/lib/dns/catz.c index 8c3b9fde69..e175badff2 100644 --- a/lib/dns/catz.c +++ b/lib/dns/catz.c @@ -1655,9 +1655,7 @@ dns_catz_generate_zonecfg(dns_catz_zone_t *zone, dns_catz_entry_t *entry, return (ISC_R_SUCCESS); cleanup: - if (buffer != NULL) { - isc_buffer_free(&buffer); - } + isc_buffer_free(&buffer); return (result); } From 331b74d6bf62726376e0f6c2603210a39b8e29ed Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 5 Feb 2020 15:47:09 +1100 Subject: [PATCH 02/19] dstkey is no longer used --- lib/dns/client.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/dns/client.c b/lib/dns/client.c index 34e65bd066..757fb42136 100644 --- a/lib/dns/client.c +++ b/lib/dns/client.c @@ -1489,7 +1489,6 @@ dns_client_addtrustedkey(dns_client_t *client, dns_rdataclass_t rdclass, { isc_result_t result; dns_view_t *view = NULL; - dst_key_t *dstkey = NULL; dns_keytable_t *secroots = NULL; dns_name_t *name = NULL; char dsbuf[DNS_DS_BUFFERSIZE]; @@ -1534,9 +1533,6 @@ dns_client_addtrustedkey(dns_client_t *client, dns_rdataclass_t rdclass, CHECK(dns_keytable_add(secroots, false, false, name, &ds)); cleanup: - if (dstkey != NULL) { - dst_key_free(&dstkey); - } if (view != NULL) { dns_view_detach(&view); } From 0be2dc9f22bf736790958fe0a4227d01bccabd3e Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 5 Feb 2020 15:50:29 +1100 Subject: [PATCH 03/19] break was on wrong line. 959 break; CID 1457872 (#1 of 1): Structurally dead code (UNREACHABLE) unreachable: This code cannot be reached: isc__nm_incstats(sock->mgr,.... 960 isc__nm_incstats(sock->mgr, sock->statsindex[STATID_ACTIVE]); 961 default: --- lib/isc/netmgr/netmgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index d7cf3a36af..41d4cce7b3 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -956,8 +956,8 @@ isc__nmsocket_init(isc_nmsocket_t *sock, isc_nm_t *mgr, } else { sock->statsindex = tcp6statsindex; } - break; isc__nm_incstats(sock->mgr, sock->statsindex[STATID_ACTIVE]); + break; default: break; } From aa101260d964db5552c6107254a545ba8d583bbb Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 5 Feb 2020 15:55:08 +1100 Subject: [PATCH 04/19] 'indentctx' is always defined. Just use it. 402 ctx->serve_stale_ttl = 0; notnull: At condition indentctx, the value of indentctx cannot be NULL. dead_error_condition: The condition indentctx must be true. CID 1456147 (#1 of 1): Logically dead code (DEADCODE) dead_error_line: Execution cannot reach the expression default_indent inside this statement: ctx->indent = (indentctx ? .... 403 ctx->indent = indentctx ? *indentctx : default_indent; --- lib/dns/masterdump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dns/masterdump.c b/lib/dns/masterdump.c index 662652bf8a..f3f02d049b 100644 --- a/lib/dns/masterdump.c +++ b/lib/dns/masterdump.c @@ -400,7 +400,7 @@ totext_ctx_init(const dns_master_style_t *style, const dns_indent_t *indentctx, ctx->current_ttl = 0; ctx->current_ttl_valid = false; ctx->serve_stale_ttl = 0; - ctx->indent = indentctx ? *indentctx : default_indent; + ctx->indent = *indentctx; return (ISC_R_SUCCESS); } From 5fc9efba3094e135700859cf02011317fbd03c1b Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 5 Feb 2020 16:00:50 +1100 Subject: [PATCH 05/19] Remove dead error code. 128 return (ISC_R_SUCCESS); 129 CID 1456146 (#1 of 1): Structurally dead code (UNREACHABLE) unreachable: This code cannot be reached: { if (dst->labels[i] != N.... 130 do { --- lib/dns/ipkeylist.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/lib/dns/ipkeylist.c b/lib/dns/ipkeylist.c index b088c1f80e..9011c018a4 100644 --- a/lib/dns/ipkeylist.c +++ b/lib/dns/ipkeylist.c @@ -126,26 +126,6 @@ dns_ipkeylist_copy(isc_mem_t *mctx, const dns_ipkeylist_t *src, } dst->count = src->count; return (ISC_R_SUCCESS); - - do { - if (dst->labels[i] != NULL) { - if (dns_name_dynamic(dst->labels[i])) - dns_name_free(dst->labels[i], mctx); - isc_mem_put(mctx, dst->labels[i], sizeof(dns_name_t)); - dst->labels[i] = NULL; - } - } while (i-- > 0); - - do { - if (dst->keys[i] != NULL) { - if (dns_name_dynamic(dst->keys[i])) - dns_name_free(dst->keys[i], mctx); - isc_mem_put(mctx, dst->keys[i], sizeof(dns_name_t)); - dst->keys[i] = NULL; - } - } while (i-- > 0); - - return (result); } isc_result_t From 1efc7550a3cf532cb5452f4c5fabe7c11a86d55a Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 5 Feb 2020 16:04:09 +1100 Subject: [PATCH 06/19] keymgr_keyrole couldn't emit "NOSIGN". 92 } else { 93 return ("ZSK"); 94 } CID 1455900 (#1 of 1): Structurally dead code (UNREACHABLE) unreachable: This code cannot be reached: return "NOSIGN";. 95 return ("NOSIGN"); --- lib/dns/keymgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dns/keymgr.c b/lib/dns/keymgr.c index 8c1441cacd..61bb3182e7 100644 --- a/lib/dns/keymgr.c +++ b/lib/dns/keymgr.c @@ -89,7 +89,7 @@ keymgr_keyrole(dst_key_t* key) return ("CSK"); } else if (ksk) { return ("KSK"); - } else { + } else if (zsk) { return ("ZSK"); } return ("NOSIGN"); From b6c3a2f172eee0dd9c734bdc0ea61ab265cb38c7 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 5 Feb 2020 16:07:31 +1100 Subject: [PATCH 07/19] remove dead cleanup code. 13836 if (zone != NULL) 13837 dns_zone_detach(&zone); null: At condition dz != NULL, the value of dz must be NULL. dead_error_condition: The condition dz != NULL cannot be true. 13838 if (dz != NULL) { CID 1453456 (#1 of 1): Logically dead code (DEADCODE) dead_error_begin: Execution cannot reach this statement: dns_zone_detach(&dz->zone);. 13839 dns_zone_detach(&dz->zone); 13840 isc_mem_put(named_g_mctx, dz, sizeof(*dz)); 13841 } --- bin/named/server.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/bin/named/server.c b/bin/named/server.c index f7f0f7dd16..0af78773b8 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -13835,10 +13835,6 @@ named_server_delzone(named_server_t *server, isc_lex_t *lex, dns_zone_detach(&raw); if (zone != NULL) dns_zone_detach(&zone); - if (dz != NULL) { - dns_zone_detach(&dz->zone); - isc_mem_put(named_g_mctx, dz, sizeof(*dz)); - } return (result); } From e4d08c023238fdbe515dc0ea7c65a7e1370893c1 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 5 Feb 2020 16:11:11 +1100 Subject: [PATCH 08/19] 'event' must be non NULL, remove test. 1401 } CID 1453455 (#1 of 1): Dereference before null check (REVERSE_INULL) check_after_deref: Null-checking event suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 1402 if (event != NULL) 1403 isc_event_free(ISC_EVENT_PTR(&event)); --- lib/dns/client.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/dns/client.c b/lib/dns/client.c index 757fb42136..ad4342be6a 100644 --- a/lib/dns/client.c +++ b/lib/dns/client.c @@ -1393,8 +1393,7 @@ dns_client_startresolve(dns_client_t *client, const dns_name_t *name, isc_mutex_destroy(&rctx->lock); isc_mem_put(mctx, rctx, sizeof(*rctx)); } - if (event != NULL) - isc_event_free(ISC_EVENT_PTR(&event)); + isc_event_free(ISC_EVENT_PTR(&event)); isc_task_detach(&tclone); dns_view_detach(&view); From 8456b5627dd36982a83778b4528ec09ade1f6dc3 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 5 Feb 2020 16:15:35 +1100 Subject: [PATCH 09/19] 'dctx' must be non NULL, remove test. 11030 cleanup: CID 1452705 (#1 of 1): Dereference before null check (REVERSE_INULL) check_after_deref: Null-checking dctx suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 11031 if (dctx != NULL) 11032 dumpcontext_destroy(dctx); 11033 return (result); --- bin/named/server.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/named/server.c b/bin/named/server.c index 0af78773b8..3acd9ad0e6 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -11028,8 +11028,7 @@ named_server_dumpdb(named_server_t *server, isc_lex_t *lex, return (ISC_R_SUCCESS); cleanup: - if (dctx != NULL) - dumpcontext_destroy(dctx); + dumpcontext_destroy(dctx); return (result); } From 1b1a94ea6da2c50702cfc6df349c4a173c7a9363 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 5 Feb 2020 16:18:50 +1100 Subject: [PATCH 10/19] 'noqname' must be non NULL, remove test. 6367cleanup: 6368 dns_rdataset_disassociate(&neg); 6369 dns_rdataset_disassociate(&negsig); CID 1452704 (#1 of 1): Dereference before null check (REVERSE_INULL) check_after_deref: Null-checking noqname suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 6370 if (noqname != NULL) 6371 free_noqname(mctx, &noqname); --- lib/dns/rbtdb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index 4c2b46c593..e2c9df1cf4 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -6368,8 +6368,7 @@ addnoqname(dns_rbtdb_t *rbtdb, rdatasetheader_t *newheader, cleanup: dns_rdataset_disassociate(&neg); dns_rdataset_disassociate(&negsig); - if (noqname != NULL) - free_noqname(mctx, &noqname); + free_noqname(mctx, &noqname); return(result); } From 2e189bb053dcc1be16db9c6a0d23755fdb892069 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 5 Feb 2020 16:28:56 +1100 Subject: [PATCH 11/19] 'stub' cannot be non NULL, remove test. 13429 cleanup: 13430 cancel_refresh(zone); CID 1452702 (#1 of 1): Dereference before null check (REVERSE_INULL) check_after_deref: Null-checking stub suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 13431 if (stub != NULL) { 13432 stub->magic = 0; --- lib/dns/zone.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/dns/zone.c b/lib/dns/zone.c index f55be93ff8..b63e1b889b 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -13428,17 +13428,18 @@ ns_query(dns_zone_t *zone, dns_rdataset_t *soardataset, dns_stub_t *stub) { cleanup: cancel_refresh(zone); - if (stub != NULL) { - stub->magic = 0; - if (stub->version != NULL) - dns_db_closeversion(stub->db, &stub->version, - false); - if (stub->db != NULL) - dns_db_detach(&stub->db); - if (stub->zone != NULL) - zone_idetach(&stub->zone); - isc_mem_put(stub->mctx, stub, sizeof(*stub)); + stub->magic = 0; + if (stub->version != NULL) { + dns_db_closeversion(stub->db, &stub->version, + false); } + if (stub->db != NULL) { + dns_db_detach(&stub->db); + } + if (stub->zone != NULL) { + zone_idetach(&stub->zone); + } + isc_mem_put(stub->mctx, stub, sizeof(*stub)); if (message != NULL) dns_message_destroy(&message); unlock: From d64921848dbec07bf07d04b6ceaa6fed878f1381 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 5 Feb 2020 16:35:15 +1100 Subject: [PATCH 12/19] cleanup error handling. 336 cleanup_mem: 337 /* cleanup memory */ 338 339 /* free tmpPath memory */ CID 1452701 (#1 of 1): Dereference before null check (REVERSE_INULL) check_after_deref: Null-checking tmpPath suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 340 if (tmpPath != NULL && result != ISC_R_SUCCESS) 341 isc_mem_free(named_g_mctx, tmpPath); 342 343 /* free tmpPath memory */ 344 return (result); --- contrib/dlz/drivers/dlz_filesystem_driver.c | 25 ++++----------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/contrib/dlz/drivers/dlz_filesystem_driver.c b/contrib/dlz/drivers/dlz_filesystem_driver.c index dbe15291d5..05ce2ef8c4 100644 --- a/contrib/dlz/drivers/dlz_filesystem_driver.c +++ b/contrib/dlz/drivers/dlz_filesystem_driver.c @@ -157,7 +157,7 @@ is_safe(const char *input) { return (true); } -static isc_result_t +static void create_path_helper(char *out, const char *in, config_data_t *cd) { char *tmpString; char *tmpPtr; @@ -206,7 +206,6 @@ create_path_helper(char *out, const char *in, config_data_t *cd) { } isc_mem_free(named_g_mctx, tmpString); - return (ISC_R_SUCCESS); } /*% @@ -223,7 +222,6 @@ create_path(const char *zone, const char *host, const char *client, char *tmpPath; int pathsize; int len; - isc_result_t result; bool isroot = false; /* we require a zone & cd parameter */ @@ -285,9 +283,7 @@ create_path(const char *zone, const char *host, const char *client, /* add zone name - parsed properly */ if (!isroot) { - result = create_path_helper(tmpPath, zone, cd); - if (result != ISC_R_SUCCESS) - goto cleanup_mem; + create_path_helper(tmpPath, zone, cd); } /* @@ -322,26 +318,13 @@ create_path(const char *zone, const char *host, const char *client, /* if host not null, add it. */ if (host != NULL) { strncat(tmpPath, (char *) &cd->pathsep, 1); - if ((result = create_path_helper(tmpPath, host, - cd)) != ISC_R_SUCCESS) - goto cleanup_mem; + create_path_helper(tmpPath, host, cd); } /* return the path we built. */ *path = tmpPath; - /* return success */ - result = ISC_R_SUCCESS; - - cleanup_mem: - /* cleanup memory */ - - /* free tmpPath memory */ - if (tmpPath != NULL && result != ISC_R_SUCCESS) - isc_mem_free(named_g_mctx, tmpPath); - - /* free tmpPath memory */ - return (result); + return (ISC_R_SUCCESS); } static isc_result_t From 0312e73e16e329ab7dd43a5e0fd4ec42af0d56c8 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 5 Feb 2020 16:37:33 +1100 Subject: [PATCH 13/19] 'closest' must be non NULL, remove test. 6412 cleanup: 6413 dns_rdataset_disassociate(&neg); 6414 dns_rdataset_disassociate(&negsig); CID 1452700 (#1 of 1): Dereference before null check (REVERSE_INULL) check_after_deref: Null-checking closest suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 6415 if (closest != NULL) 6416 free_noqname(mctx, &closest); --- lib/dns/rbtdb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index e2c9df1cf4..97c328041d 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -6412,8 +6412,7 @@ addclosest(dns_rbtdb_t *rbtdb, rdatasetheader_t *newheader, cleanup: dns_rdataset_disassociate(&neg); dns_rdataset_disassociate(&negsig); - if (closest != NULL) - free_noqname(mctx, &closest); + free_noqname(mctx, &closest); return(result); } From 44b08521ef11e550ec5edea7378458aad8f2a89f Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 5 Feb 2020 16:41:03 +1100 Subject: [PATCH 14/19] 'tql' must be non NULL, remove test. 255 flag_fail: 256 /* get rid of what was build of the query list */ CID 1452697 (#1 of 1): Dereference before null check (REVERSE_INULL) check_after_deref: Null-checking tql suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 257 if (tql != NULL) 258 destroy_querylist(mctx, &tql); --- contrib/dlz/drivers/sdlz_helper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contrib/dlz/drivers/sdlz_helper.c b/contrib/dlz/drivers/sdlz_helper.c index 889a8a6ee8..6eb6629245 100644 --- a/contrib/dlz/drivers/sdlz_helper.c +++ b/contrib/dlz/drivers/sdlz_helper.c @@ -254,8 +254,7 @@ build_querylist(isc_mem_t *mctx, const char *query_str, char **zone, flag_fail: /* get rid of what was build of the query list */ - if (tql != NULL) - destroy_querylist(mctx, &tql); + destroy_querylist(mctx, &tql); return result; } From 714594d4689b77f174a7638861d9f3dc20f31f87 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 5 Feb 2020 16:43:12 +1100 Subject: [PATCH 15/19] 's' must be non NULL, remove test. 122 cleanup: CID 1452696 (#1 of 1): Dereference before null check (REVERSE_INULL) check_after_deref: Null-checking s suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 123 if (s != NULL) 124 isc_mem_free(mctx, s); --- bin/tests/system/dyndb/driver/driver.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/tests/system/dyndb/driver/driver.c b/bin/tests/system/dyndb/driver/driver.c index 887c9b5da9..27b8a8fc44 100644 --- a/bin/tests/system/dyndb/driver/driver.c +++ b/bin/tests/system/dyndb/driver/driver.c @@ -120,8 +120,7 @@ dyndb_init(isc_mem_t *mctx, const char *name, const char *parameters, *instp = sample_inst; cleanup: - if (s != NULL) - isc_mem_free(mctx, s); + isc_mem_free(mctx, s); if (argv != NULL) isc_mem_put(mctx, argv, argc * sizeof(*argv)); From 7ba1af0280b90d3faa25da50910bc78e667844a3 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 5 Feb 2020 16:45:59 +1100 Subject: [PATCH 16/19] '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); } From bf7a99a3c1c1d9d355d37a14f15390f4d2be80f5 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 5 Feb 2020 16:49:09 +1100 Subject: [PATCH 17/19] 'dir_list' must be non NULL, remove test. 707 complete_allnds: CID 1452689 (#1 of 1): Dereference before null check (REVERSE_INULL) check_after_deref: Null-checking dir_list suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 708 if (dir_list != NULL) { 709 /* clean up entries from list. */ --- contrib/dlz/drivers/dlz_filesystem_driver.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/contrib/dlz/drivers/dlz_filesystem_driver.c b/contrib/dlz/drivers/dlz_filesystem_driver.c index 05ce2ef8c4..a3fe98dd67 100644 --- a/contrib/dlz/drivers/dlz_filesystem_driver.c +++ b/contrib/dlz/drivers/dlz_filesystem_driver.c @@ -688,19 +688,18 @@ fs_allnodes(const char *zone, void *driverarg, void *dbdata, } /* end while */ complete_allnds: - if (dir_list != NULL) { - /* clean up entries from list. */ - dir_entry = ISC_LIST_HEAD(*dir_list); - while (dir_entry != NULL) { - next_de = ISC_LIST_NEXT(dir_entry, link); - isc_mem_put(named_g_mctx, dir_entry, sizeof(dir_entry_t)); - dir_entry = next_de; - } /* end while */ - isc_mem_put(named_g_mctx, dir_list, sizeof(dlist_t)); - } + /* clean up entries from list. */ + dir_entry = ISC_LIST_HEAD(*dir_list); + while (dir_entry != NULL) { + next_de = ISC_LIST_NEXT(dir_entry, link); + isc_mem_put(named_g_mctx, dir_entry, sizeof(dir_entry_t)); + dir_entry = next_de; + } /* end while */ + isc_mem_put(named_g_mctx, dir_list, sizeof(dlist_t)); - if (basepath != NULL) + if (basepath != NULL) { isc_mem_free(named_g_mctx, basepath); + } return (result); } From fccf65a5852da5fa399f0720469f77555f49998b Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 5 Feb 2020 16:51:01 +1100 Subject: [PATCH 18/19] 'dctx' must be non NULL, remove test. 1549 cleanup: 1550 if (dctx->dbiter != NULL) 1551 dns_dbiterator_destroy(&dctx->dbiter); 1552 if (dctx->db != NULL) 1553 dns_db_detach(&dctx->db); CID 1452686 (#1 of 1): Dereference before null check (REVERSE_INULL) check_after_deref: Null-checking dctx suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 1554 if (dctx != NULL) 1555 isc_mem_put(mctx, dctx, sizeof(*dctx)); --- lib/dns/masterdump.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/dns/masterdump.c b/lib/dns/masterdump.c index f3f02d049b..b5adeb532e 100644 --- a/lib/dns/masterdump.c +++ b/lib/dns/masterdump.c @@ -1547,12 +1547,13 @@ dumpctx_create(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, return (ISC_R_SUCCESS); cleanup: - if (dctx->dbiter != NULL) + if (dctx->dbiter != NULL) { dns_dbiterator_destroy(&dctx->dbiter); - if (dctx->db != NULL) + } + if (dctx->db != NULL) { dns_db_detach(&dctx->db); - if (dctx != NULL) - isc_mem_put(mctx, dctx, sizeof(*dctx)); + } + isc_mem_put(mctx, dctx, sizeof(*dctx)); return (result); } From 891f24fa57ae8fba02eb21f32ce5fb40a080efc9 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 5 Feb 2020 16:53:43 +1100 Subject: [PATCH 19/19] 'dispatch' must be non NULL, remove test. 10067 cleanup: CID 1452683 (#1 of 1): Dereference before null check (REVERSE_INULL) check_after_deref: Null-checking dispatch suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 10068 if (dispatch != NULL) 10069 isc_mem_put(server->mctx, dispatch, sizeof(*dispatch)); --- bin/named/server.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/named/server.c b/bin/named/server.c index 3acd9ad0e6..6a818a3149 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -10065,8 +10065,7 @@ named_add_reserved_dispatch(named_server_t *server, return; cleanup: - if (dispatch != NULL) - isc_mem_put(server->mctx, dispatch, sizeof(*dispatch)); + isc_mem_put(server->mctx, dispatch, sizeof(*dispatch)); isc_sockaddr_format(addr, addrbuf, sizeof(addrbuf)); isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,