summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2017-02-25 11:02:28 +0100
committerJunio C Hamano <gitster@pobox.com>2017-02-27 11:00:30 -0800
commit886ddf4777d119f0a420bdf55fba834c16c58069 (patch)
tree296215f46527ab3af2f4a289fc7b7dd3840497e5
parentc3808ca6982b0ad7ee9b87eca9b50b9a24ec08b0 (diff)
downloadgit-886ddf4777d119f0a420bdf55fba834c16c58069.tar.gz
sha1_file: release fallback base's memory in unpack_entry()rs/sha1-file-plug-fallback-base-leak
If a pack entry that's used as a delta base is corrupt, unpack_entry() marks it as unusable and then searches the object again in the hope that it can be found in another pack or in a loose file. The memory for this external base object is never released. Free it after use. Signed-off-by: Rene Scharfe <l.s.r@web.de> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--sha1_file.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 727a9769fb..9a16e3841c 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2351,6 +2351,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
while (delta_stack_nr) {
void *delta_data;
void *base = data;
+ void *external_base = NULL;
unsigned long delta_size, base_size = size;
int i;
@@ -2377,6 +2378,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
p->pack_name);
mark_bad_packed_object(p, base_sha1);
base = read_object(base_sha1, &type, &base_size);
+ external_base = base;
}
}
@@ -2395,6 +2397,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
"at offset %"PRIuMAX" from %s",
(uintmax_t)curpos, p->pack_name);
data = NULL;
+ free(external_base);
continue;
}
@@ -2414,6 +2417,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
error("failed to apply delta");
free(delta_data);
+ free(external_base);
}
*final_type = type;