Skip to content

Conversation

@pks-t
Copy link
Member

@pks-t pks-t commented Dec 1, 2015

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.

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.
@vmg
Copy link
Member

vmg commented Dec 1, 2015

Nice spotting. cc @carlosmn

@ethomson
Copy link
Member

ethomson commented Dec 1, 2015

👍

ethomson added a commit that referenced this pull request Dec 1, 2015
tree: mark cloned tree entries as un-pooled
@ethomson ethomson merged commit 15e6a5a into libgit2:master Dec 1, 2015
@pks-t pks-t deleted the pks/tree-entry-memleak branch December 1, 2015 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants