]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Move isc_mem_put to after node is checked for equality
authorMark Andrews <marka@isc.org>
Fri, 26 May 2023 00:28:39 +0000 (10:28 +1000)
committerMark Andrews <marka@isc.org>
Mon, 29 May 2023 01:40:57 +0000 (01:40 +0000)
isc_mem_put NULL's the pointer to the memory being freed.  The
equality test 'parent->r == node' was accidentally being turned
into a test against NULL.

lib/isc/radix.c

index d84e5d03020291cc57a715b334299326710745a5..54c03832f1f670f1a908b0d33c3a2f879760890a 100644 (file)
@@ -694,13 +694,13 @@ isc_radix_remove(isc_radix_tree_t *radix, isc_radix_node_t *node) {
                return;
        }
 
-       isc_mem_put(radix->mctx, node, sizeof(*node));
-       radix->num_active_node--;
-
        if (parent->r == node) {
                parent->r = child;
        } else {
                INSIST(parent->l == node);
                parent->l = child;
        }
+
+       isc_mem_put(radix->mctx, node, sizeof(*node));
+       radix->num_active_node--;
 }