From: Olivier Matz Date: Sun, 12 Aug 2018 12:56:11 +0000 (+0200) Subject: fix node free X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=da2ebd0f34978c5111a2adfb13fb6ba841edf618;p=protos%2Flibecoli.git fix node free --- 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); }