sha1_file: fix delta_stack memory leak in unpack_entry
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Thu, 20 Feb 2014 23:47:47 +0000 (06:47 +0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 24 Feb 2014 17:07:12 +0000 (09:07 -0800)
This delta_stack array can grow to any length depending on the actual
delta chain, but we forget to free it. Normally it does not matter
because we use small_delta_stack[] from stack and small_delta_stack
can hold 64-delta chains, more than standard --depth=50 in pack-objects.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_file.c
index b220a470f9800e0e1120ede593dcf775921f633f..ca31de2df91ff34c7f298940d1fed23ce1ea1557 100644 (file)
@@ -2058,6 +2058,10 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
        *final_size = size;
 
        unuse_pack(&w_curs);
+
+       if (delta_stack != small_delta_stack)
+               free(delta_stack);
+
        return data;
 }