Skip to content

Commit 896dca3

Browse files
rscharfegitster
authored andcommitted
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>
1 parent 3d9c5b5 commit 896dca3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

sha1_file.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2462,8 +2462,8 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
24622462
error("bad packed object CRC for %s",
24632463
sha1_to_hex(sha1));
24642464
mark_bad_packed_object(p, sha1);
2465-
unuse_pack(&w_curs);
2466-
return NULL;
2465+
data = NULL;
2466+
goto out;
24672467
}
24682468
}
24692469

@@ -2599,6 +2599,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
25992599
*final_type = type;
26002600
*final_size = size;
26012601

2602+
out:
26022603
unuse_pack(&w_curs);
26032604

26042605
if (delta_stack != small_delta_stack)

0 commit comments

Comments
 (0)