unpack-trees: plug a memory leak
authorFelipe Contreras <redacted>
Tue, 13 Aug 2013 18:27:58 +0000 (20:27 +0200)
committerJunio C Hamano <redacted>
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 <redacted>
Tested-by: Лежанкин Иван <redacted> wrote:
Reviewed-by: René Scharfe <redacted>
Signed-off-by: Junio C Hamano <redacted>
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);
git clone https://git.99rst.org/PROJECT