From: Mark Andrews Date: Fri, 26 May 2023 00:28:39 +0000 (+1000) Subject: Move isc_mem_put to after node is checked for equality X-Git-Tag: v9.19.14~23^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ac2e0bc3ff375807638cfd508f417a80290a37e8;p=thirdparty%2Fbind9.git Move isc_mem_put to after node is checked for equality 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. --- diff --git a/lib/isc/radix.c b/lib/isc/radix.c index d84e5d03020..54c03832f1f 100644 --- a/lib/isc/radix.c +++ b/lib/isc/radix.c @@ -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--; }