diff --git a/proto/aggregator/aggregator.c b/proto/aggregator/aggregator.c index 2065f951..d0b8124e 100644 --- a/proto/aggregator/aggregator.c +++ b/proto/aggregator/aggregator.c @@ -95,9 +95,11 @@ static void remove_node(struct trie_node *node) { assert(node != NULL); - assert(node->parent != NULL); assert(node->child[0] == NULL && node->child[1] == NULL); + if (node->parent == NULL) + goto free_node; + if (node->parent->child[0] == node) node->parent->child[0] = NULL; else if (node->parent->child[1] == node) @@ -105,7 +107,8 @@ remove_node(struct trie_node *node) else bug("Invalid child pointer"); - sl_free(node); + free_node: + sl_free(node); } static void