Permalink
Browse files

unpack-trees: plug a memory leak

Before overwriting the destination index, first let's discard its
contents.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Tested-by: Лежанкин Иван <abyss.7@gmail.com> wrote:
Reviewed-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information...
1 parent 425df88 commit e28f7641592c5b907df2f084112fa22a31500810 @felipec felipec committed with gitster Aug 13, 2013
Showing with 3 additions and 1 deletion.
  1. +3 −1 unpack-trees.c
View
4 unpack-trees.c
@@ -1154,8 +1154,10 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
o->src_index = NULL;
ret = check_updates(o) ? (-2) : 0;
- if (o->dst_index)
+ if (o->dst_index) {
+ discard_index(o->dst_index);
*o->dst_index = o->result;
+ }
done:
clear_exclude_list(&el);

0 comments on commit e28f764

Please sign in to comment.