From 39edcc9862ce7ccb90b9059960f54733ee4d590b Mon Sep 17 00:00:00 2001 From: "Nathan S. Evans" Date: Thu, 3 Dec 2009 01:44:18 +0000 Subject: [PATCH] heap bugfix --- src/util/container_heap.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/util/container_heap.c b/src/util/container_heap.c index cde678257..9c6005beb 100644 --- a/src/util/container_heap.c +++ b/src/util/container_heap.c @@ -326,6 +326,8 @@ GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_Heap *root, ret = del_node->element; last = getPos (root, root->size); + root->size--; + old_cost = del_node->cost; del_node->element = last->element; del_node->cost = last->cost; @@ -339,8 +341,14 @@ GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_Heap *root, { root->traversal_pos = root->root; } + + if (last == del_node) + { + GNUNET_free (last); + return ret; + } GNUNET_free (last); - root->size--; + if (del_node->cost > old_cost) { -- 2.25.1