unpack-trees: plug a memory leak
authorFelipe Contreras <felipe.contreras@gmail.com>
Tue, 13 Aug 2013 18:27:58 +0000 (20:27 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 13 Aug 2013 21:37:30 +0000 (14:37 -0700)
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>
unpack-trees.c
index bf01717015b662cec594d2d3c73e57f409037533..1a61e6f363d6a03b262ad5e5a28c58c2caf722d5 100644 (file)
@@ -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);