Skip to content

Commit

Permalink
unpack-trees: plug a memory leak
Browse files Browse the repository at this point in the history
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
Felipe Contreras authored and Junio C Hamano committed Aug 13, 2013
1 parent 425df88 commit e28f764
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion unpack-trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e28f764

Please sign in to comment.