From 27eb8ed20f06f34e5ced8ea0547767fdfb2db538 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Fri, 26 May 2023 10:28:39 +1000 Subject: [PATCH] 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. (cherry picked from commit ac2e0bc3ff375807638cfd508f417a80290a37e8) --- lib/isc/radix.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/isc/radix.c b/lib/isc/radix.c index d84e5d0302..54c03832f1 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--; }