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>

Felipe Contreras committed Aug 13, 2013 at 20:27 UTC e28f7641592c5b907df2f084112fa22a31500810
1 file changed +3 -1
unpack-trees.c
+3 -1
@@ -1154,8 +1154,10 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
1154
1155 o->src_index = NULL;
1156 ret = check_updates(o) ? (-2) : 0;
1157 - if (o->dst_index)
1157 + if (o->dst_index) {
1158 + discard_index(o->dst_index);
1159 *o->dst_index = o->result;
1160 + }
1161
1162 done:
1163 clear_exclude_list(&el);