diff options
author | Jonathan Nieder <jrnieder@gmail.com> | 2010-08-09 22:33:44 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-08-11 09:58:18 -0700 |
commit | 1ce584b05843dfa8b0fe31ed3d75bddf1c29c4e0 (patch) | |
tree | 0efcbf74ca34c65f5d743820b15eda18db61dbc4 | |
parent | 59efba64ac144a8838a35ae687b8c5bb6cd43363 (diff) | |
download | git-1ce584b05843dfa8b0fe31ed3d75bddf1c29c4e0.tar.gz git-1ce584b05843dfa8b0fe31ed3d75bddf1c29c4e0.tar.xz |
read-tree: stop leaking tree objects
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>
-rw-r--r-- | unpack-trees.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/unpack-trees.c b/unpack-trees.c index 8cf0da317..f561d8815 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -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; @@ -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; } |