Fix mem leak - dedup - deduplicating backup program (HTM) git clone git://bitreich.org/dedup/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/dedup/ (DIR) Log (DIR) Files (DIR) Refs (DIR) Tags (DIR) README (DIR) LICENSE --- (DIR) commit 13ea526261fd0d7821dbf271bd9ccd509ae4e6fd (DIR) parent 2646d0e4e3cbc7b6fe481958d112d7ba1d654911 (HTM) Author: sin <sin@2f30.org> Date: Tue, 5 Mar 2019 13:52:27 +0000 Fix mem leak If the node already exists in the rb-tree a pointer to it is returned. In that case we can free the temporary node that was allocated because it will not be used. Diffstat: M cache.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- (DIR) diff --git a/cache.c b/cache.c @@ -83,7 +83,8 @@ add_cache_entry(struct cache *cache, struct cache_entry *ent) struct cache_node *node; node = alloc_cache_node(ent); - RB_INSERT(cache_head, &cache->nodes, node); + if (RB_INSERT(cache_head, &cache->nodes, node) != NULL) + free_cache_node(node); } int