From 03b68b8c383bead09e3208e17aa803b692467d41 Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Wed, 7 Feb 2024 09:22:55 +0000 Subject: [PATCH] Address scan-build warnings The warnings (see below) seem to be false-positives. Address them by adding runtime checks. resolver.c:1627:10: warning: Access to field 'tid' results in a dereference of a null pointer (loaded from variable 'fctx') [core.NullDereference] 1627 | REQUIRE(fctx->tid == isc_tid()); | ^~~~~~~~~ ../../lib/isc/include/isc/util.h:332:34: note: expanded from macro 'REQUIRE' 332 | #define REQUIRE(e) ISC_REQUIRE(e) | ^ ../../lib/isc/include/isc/assertions.h:45:11: note: expanded from macro 'ISC_REQUIRE' 45 | ((void)((cond) || \ | ^~~~ resolver.c:10335:6: warning: Access to field 'depth' results in a dereference of a null pointer (loaded from variable 'fctx') [core.NullDereference] 10335 | if (fctx->depth > depth) { | ^~~~~~~~~~~ 2 warnings generated. --- lib/dns/resolver.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 0395587ed1..5f30be8645 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -1641,6 +1641,7 @@ fctx__done(fetchctx_t *fctx, isc_result_t result, const char *func, bool no_response = false; bool age_untried = false; + REQUIRE(fctx != NULL); REQUIRE(fctx->tid == isc_tid()); FCTXTRACE("done"); @@ -10353,6 +10354,8 @@ dns_resolver_createfetch(dns_resolver_t *res, const dns_name_t *name, new_fctx = true; } + RUNTIME_CHECK(fctx != NULL); + if (fctx->depth > depth) { fctx->depth = depth; }