Skip to content

Commit

Permalink
read-tree: stop leaking tree objects
Browse files Browse the repository at this point in the history
The underlying problem is that the fill_tree_descriptor()
API is easy to misuse, and this patch does not fix that.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jonathan Nieder authored and Junio C Hamano committed Aug 11, 2010
1 parent 59efba6 commit 1ce584b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion unpack-trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ static int traverse_trees_recursive(int n, unsigned long dirmask, unsigned long
{
int i, ret, bottom;
struct tree_desc t[MAX_UNPACK_TREES];
void *buf[MAX_UNPACK_TREES];
struct traverse_info newinfo;
struct name_entry *p;

Expand All @@ -346,12 +347,16 @@ static int traverse_trees_recursive(int n, unsigned long dirmask, unsigned long
const unsigned char *sha1 = NULL;
if (dirmask & 1)
sha1 = names[i].sha1;
fill_tree_descriptor(t+i, sha1);
buf[i] = fill_tree_descriptor(t+i, sha1);
}

bottom = switch_cache_bottom(&newinfo);
ret = traverse_trees(n, t, &newinfo);
restore_cache_bottom(&newinfo, bottom);

for (i = 0; i < n; i++)
free(buf[i]);

return ret;
}

Expand Down

0 comments on commit 1ce584b

Please sign in to comment.