sha1_file: release delta_stack on error in unpack_entry()
authorRené Scharfe <l.s.r@web.de>
Thu, 10 Aug 2017 09:42:21 +0000 (11:42 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 10 Aug 2017 22:42:46 +0000 (15:42 -0700)
When unpack_entry() encounters a broken packed object, it returns early.
It adjusts the reference count of the pack window, but leaks the buffer
for a big delta stack in case the small automatic one was not enough.
Jump to the cleanup code at end instead, which takes care of that.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_file.c
index d77b915db699f6f58731f645d6bcc188843d9eb8..ba282c06bd5b2863b1fa86665ce1904124d2890b 100644 (file)
@@ -2462,8 +2462,8 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
                                error("bad packed object CRC for %s",
                                      sha1_to_hex(sha1));
                                mark_bad_packed_object(p, sha1);
-                               unuse_pack(&w_curs);
-                               return NULL;
+                               data = NULL;
+                               goto out;
                        }
                }
 
@@ -2599,6 +2599,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
        *final_type = type;
        *final_size = size;
 
+out:
        unuse_pack(&w_curs);
 
        if (delta_stack != small_delta_stack)