]> git.droids-corp.org - protos/libecoli.git/commitdiff
fix node free
authorOlivier Matz <zer0@droids-corp.org>
Sun, 12 Aug 2018 12:56:11 +0000 (14:56 +0200)
committerOlivier Matz <zer0@droids-corp.org>
Sun, 12 Aug 2018 12:56:11 +0000 (14:56 +0200)
lib/ecoli_node.c

index 129a44a349497e31b22e5e843705e85b8221b04a..c02a8dedc1703632b7582845d4a756aa556a85dc 100644 (file)
@@ -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);
 }