diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2016-07-04 23:59:06 +0200 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2016-07-05 02:51:46 +0200 |
commit | f416c85366a3e85e7f7576398f55595de51adc52 (patch) | |
tree | 8fdb0a91865eaa8a58c84d3e97112601b318b460 /src/utils.c | |
parent | 4c228763c31255ea9bd3cd1bbd93f5cf7ab9f54b (diff) | |
download | blogc-f416c85366a3e85e7f7576398f55595de51adc52.tar.gz blogc-f416c85366a3e85e7f7576398f55595de51adc52.tar.bz2 blogc-f416c85366a3e85e7f7576398f55595de51adc52.zip |
renderer: utils: fixed memory bugs found by clang static analyzer
Diffstat (limited to 'src/utils.c')
-rw-r--r-- | src/utils.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/utils.c b/src/utils.c index d7362a6..9a39c61 100644 --- a/src/utils.c +++ b/src/utils.c @@ -622,22 +622,19 @@ sb_trie_foreach_node(sb_trie_node_t *node, sb_string_t *str, return; if (node->key == '\0') { - char *tmp = sb_string_free(str, false); - func(tmp, node->data, user_data); - free(tmp); + func(str->str, node->data, user_data); + return; } if (node->child != NULL) { sb_string_t *child = sb_string_dup(str); child = sb_string_append_c(child, node->key); sb_trie_foreach_node(node->child, child, func, user_data); + sb_string_free(child, true); } if (node->next != NULL) sb_trie_foreach_node(node->next, str, func, user_data); - - if (node->child != NULL && node->next == NULL) - sb_string_free(str, true); } @@ -650,4 +647,5 @@ sb_trie_foreach(sb_trie_t *trie, sb_trie_foreach_func_t func, sb_string_t *str = sb_string_new(); sb_trie_foreach_node(trie->root, str, func, user_data); + sb_string_free(str, true); } |