]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Silence CID 329157: Dereference before null check in lib/dns/journal.c
authorMark Andrews <marka@isc.org>
Sun, 7 Mar 2021 20:06:57 +0000 (07:06 +1100)
committerMark Andrews <marka@isc.org>
Mon, 8 Mar 2021 05:12:01 +0000 (16:12 +1100)
    *** CID 329157:  Null pointer dereferences  (REVERSE_INULL)
    /lib/dns/journal.c: 754 in journal_open()
    748          j->header.index_size * sizeof(journal_rawpos_t));
    749      }
    750      if (j->index != NULL) {
    751      isc_mem_put(j->mctx, j->index,
    752          j->header.index_size * sizeof(journal_pos_t));
    753      }
       CID 329157:  Null pointer dereferences  (REVERSE_INULL)
       Null-checking "j->filename" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
    754      if (j->filename != NULL) {
    755      isc_mem_free(j->mctx, j->filename);
    756      }
    757      if (j->fp != NULL) {
    758      (void)isc_stdio_close(j->fp);
    759      }

(cherry picked from commit 405440590947fdc881ffc1bf2cd1ed5c2026a03b)

lib/dns/journal.c

index fad38c0f5796890023e407898654da8ecb845a3b..741da8c294c8f090824a62080aff7a3f7dd140e8 100644 (file)
@@ -751,9 +751,7 @@ failure:
                isc_mem_put(j->mctx, j->index,
                            j->header.index_size * sizeof(journal_pos_t));
        }
-       if (j->filename != NULL) {
-               isc_mem_free(j->mctx, j->filename);
-       }
+       isc_mem_free(j->mctx, j->filename);
        if (j->fp != NULL) {
                (void)isc_stdio_close(j->fp);
        }