From da2ebd0f34978c5111a2adfb13fb6ba841edf618 Mon Sep 17 00:00:00 2001 From: Olivier Matz Date: Sun, 12 Aug 2018 14:56:11 +0200 Subject: [PATCH] fix node free --- lib/ecoli_node.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/ecoli_node.c b/lib/ecoli_node.c index 129a44a..c02a8de 100644 --- a/lib/ecoli_node.c +++ b/lib/ecoli_node.c @@ -234,11 +234,17 @@ void ec_node_free(struct ec_node *node) if (node->free.state != EC_NODE_FREE_STATE_FREEING) { node->free.state = EC_NODE_FREE_STATE_FREEING; + + /* children will be freed by config_free() and free_priv() */ + ec_config_free(node->config); + node->config = NULL; n = ec_node_get_children_count(node); - /* children should be freed by free_priv() */ assert(n == 0 || node->type->free_priv != NULL); if (node->type->free_priv != NULL) node->type->free_priv(node); + ec_free(node->id); + ec_free(node->desc); + ec_keyval_free(node->attrs); } node->refcnt--; @@ -248,10 +254,6 @@ void ec_node_free(struct ec_node *node) node->free.state = EC_NODE_FREE_STATE_NONE; node->free.refcnt = 0; - ec_free(node->id); - ec_free(node->desc); - ec_keyval_free(node->attrs); - ec_config_free(node->config); ec_free(node); } -- 2.39.5