From 9487585ddc5d7cbb8b9d085e030a01ff805bc41b Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 1 Dec 2015 14:19:29 +0100 Subject: [PATCH] tree: mark cloned tree entries as un-pooled When duplicating a `struct git_tree_entry` with `git_tree_entry_dup` the resulting structure is not allocated inside a memory pool. As we do a 1:1 copy of the original struct, though, we also copy the `pooled` field, which is set to `true` for pooled entries. This results in a huge memory leak as we never free tree entries that were duplicated from a pooled tree entry. Fix this by marking the newly duplicated entry as un-pooled. --- src/tree.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tree.c b/src/tree.c index 0a32868cd..0e3738afa 100644 --- a/src/tree.c +++ b/src/tree.c @@ -253,6 +253,8 @@ int git_tree_entry_dup(git_tree_entry **dest, const git_tree_entry *source) memcpy(copy, source, total_size); + copy->pooled = 0; + *dest = copy; return 0; }