sha1_file: release delta_stack on error in unpack_entry()

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>

René Scharfe committed Aug 10, 2017 at 11:42 UTC 896dca3ab75de69e292d7863d704b3e7a8f1a59d
1 file changed +3 -2
sha1_file.c
+3 -2
@@ -2462,8 +2462,8 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
2462 error("bad packed object CRC for %s",
2463 sha1_to_hex(sha1));
2464 mark_bad_packed_object(p, sha1);
2465 - unuse_pack(&w_curs);
2466 - return NULL;
2465 + data = NULL;
2466 + goto out;
2467 }
2468 }
2469
@@ -2599,6 +2599,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
2599 *final_type = type;
2600 *final_size = size;
2601
2602 +out:
2603 unuse_pack(&w_curs);
2604
2605 if (delta_stack != small_delta_stack)