]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Silence a scan-build warning in dns_rbt_addname()
authorMichał Kępień <michal@isc.org>
Fri, 22 Dec 2023 18:27:37 +0000 (19:27 +0100)
committerMichał Kępień <michal@isc.org>
Fri, 22 Dec 2023 18:27:37 +0000 (19:27 +0100)
Clang Static Analyzer is unable to grasp that when dns_rbt_addnode()
returns ISC_R_EXISTS, it always sets the pointer passed to it via its
'nodep' parameter to a non-NULL value.  Add an extra safety check in the
conditional expression used in dns_rbt_addname() to silence that
warning.

lib/dns/rbt.c

index 07028f6b1336dc0620910b17ec166f95ca9d0849..54ddfd917514b9710784b1d9226f83531873d6bb 100644 (file)
@@ -733,7 +733,7 @@ dns_rbt_addname(dns_rbt_t *rbt, const dns_name_t *name, void *data) {
         * there is data associated with a node.
         */
        if (result == ISC_R_SUCCESS ||
-           (result == ISC_R_EXISTS && node->data == NULL))
+           (result == ISC_R_EXISTS && node != NULL && node->data == NULL))
        {
                node->data = data;
                result = ISC_R_SUCCESS;