From 804dfa9a29a52ebe59bbf93d222adde3c1c3938c Mon Sep 17 00:00:00 2001 From: Olivier Matz Date: Sun, 12 Aug 2018 14:56:23 +0200 Subject: [PATCH] better cleanup priv This is useful to avoid a segfault when debugging a node beeing freed: when the priv is freed, get_child_count() must return 0, because the node table is empty. --- lib/ecoli_node_cmd.c | 6 ++++++ lib/ecoli_node_seq.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/lib/ecoli_node_cmd.c b/lib/ecoli_node_cmd.c index 428f453..c61b759 100644 --- a/lib/ecoli_node_cmd.c +++ b/lib/ecoli_node_cmd.c @@ -415,12 +415,18 @@ static void ec_node_cmd_free_priv(struct ec_node *gen_node) size_t i; ec_free(node->cmd_str); + node->cmd_str = NULL; ec_node_free(node->expr); + node->expr = NULL; ec_node_free(node->parser); + node->parser = NULL; ec_node_free(node->cmd); + node->cmd = NULL; for (i = 0; i < node->len; i++) ec_node_free(node->table[i]); ec_free(node->table); + node->table = NULL; + node->len = 0; } static const struct ec_config_schema ec_node_cmd_subschema[] = { diff --git a/lib/ecoli_node_seq.c b/lib/ecoli_node_seq.c index dc6954d..ff0c5de 100644 --- a/lib/ecoli_node_seq.c +++ b/lib/ecoli_node_seq.c @@ -164,6 +164,8 @@ static void ec_node_seq_free_priv(struct ec_node *gen_node) for (i = 0; i < node->len; i++) ec_node_free(node->table[i]); ec_free(node->table); + node->table = NULL; + node->len = 0; } static const struct ec_config_schema ec_node_seq_subschema[] = { -- 2.39.5