From: Wouter Wijngaards Date: Thu, 15 Feb 2007 15:32:02 +0000 (+0000) Subject: Fixup - rebalancing the tree during delete would be bad. X-Git-Tag: release-0.0~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b935c07152a2202dc01abc96f1d5b39c0eb8d37;p=thirdparty%2Funbound.git Fixup - rebalancing the tree during delete would be bad. git-svn-id: file:///svn/unbound/trunk@108 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/services/outside_network.c b/services/outside_network.c index 9c95f6978..f6755c044 100644 --- a/services/outside_network.c +++ b/services/outside_network.c @@ -350,7 +350,8 @@ outside_network_delete(struct outside_network* outnet) return; /* check every element, since we can be called on malloc error */ if(outnet->pending) { - traverse_postorder(outnet->pending, pending_node_del, outnet); + /* free pending elements, but do no unlink from tree. */ + traverse_postorder(outnet->pending, pending_node_del, NULL); free(outnet->pending); } if(outnet->udp_buff) diff --git a/util/rbtree.h b/util/rbtree.h index 8b5b7acd9..dab886a83 100644 --- a/util/rbtree.h +++ b/util/rbtree.h @@ -183,8 +183,11 @@ rbnode_t *rbtree_previous(rbnode_t *rbtree); * Call function for all elements in the redblack tree, such that * leaf elements are called before parent elements. So that all * elements can be safely free()d. + * Note that your function must not remove the nodes from the tree. + * Since that may trigger rebalances of the rbtree. * @param tree: the tree * @param func: function called with element and user arg. + * The function must not alter the rbtree. * @param arg: user argument. */ void traverse_postorder(rbtree_t* tree, void (*func)(rbnode_t*, void*),