]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Address scan-build warnings
authorAram Sargsyan <aram@isc.org>
Wed, 7 Feb 2024 09:22:55 +0000 (09:22 +0000)
committerAram Sargsyan <aram@isc.org>
Fri, 16 Feb 2024 08:42:48 +0000 (08:42 +0000)
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

index 0395587ed131ded864ca28fb48b39dd2f9b476e8..5f30be8645179a33c1bf260cc44bf09a1e2d521d 100644 (file)
@@ -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;
        }