summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2017-08-10 11:42:21 +0200
committerJunio C Hamano <gitster@pobox.com>2017-08-10 15:42:46 -0700
commit896dca3ab75de69e292d7863d704b3e7a8f1a59d (patch)
treec1e93dc5b2b5d209797793bf690c912b91300dc8
parent3d9c5b5c4461957fbbc0479e037990db04ebb740 (diff)
downloadgit-rs/unpack-entry-leakfix.tar.gz
sha1_file: release delta_stack on error in unpack_entry()rs/unpack-entry-leakfix
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>
-rw-r--r--sha1_file.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sha1_file.c b/sha1_file.c
index d77b915db6..ba282c06bd 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -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)