dedup

deduplicating backup program
git clone git://git.2f30.org/dedup
Log | Files | Refs | README | LICENSE

commit 13ea526261fd0d7821dbf271bd9ccd509ae4e6fd
parent 2646d0e4e3cbc7b6fe481958d112d7ba1d654911
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:
Mcache.c | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

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