aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/trie.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/utils/trie.c b/src/utils/trie.c
index f1b77eb..e0ac1af 100644
--- a/src/utils/trie.c
+++ b/src/utils/trie.c
@@ -82,8 +82,9 @@ b_trie_insert(b_trie_t *trie, const char *key, void *data)
parent = tmp;
- if (previous == NULL || parent != NULL)
+ if (previous == NULL || parent != NULL) {
goto clean;
+ }
current = b_malloc(sizeof(b_trie_node_t));
current->key = *key;
@@ -95,6 +96,8 @@ b_trie_insert(b_trie_t *trie, const char *key, void *data)
clean:
if (*key == '\0') {
+ if (parent->data != NULL && trie->free_func != NULL)
+ trie->free_func(parent->data);
parent->data = data;
break;
}