summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-03-10 21:24:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-03-10 21:24:23 (GMT)
commit82682e218a4ebe980345908c31ac9976f7ef4283 (patch)
tree8a2b92eee265e98ad202d1a0013070f86c8e4bfc
parent98c96f8bffe315dc82f694d50a4c83567a4ee133 (diff)
parent886ddf4777d119f0a420bdf55fba834c16c58069 (diff)
downloadgit-82682e218a4ebe980345908c31ac9976f7ef4283.zip
git-82682e218a4ebe980345908c31ac9976f7ef4283.tar.gz
git-82682e218a4ebe980345908c31ac9976f7ef4283.tar.bz2
Merge branch 'rs/sha1-file-plug-fallback-base-leak'
A leak in a codepath to read from a packed object in (rare) cases has been plugged. * rs/sha1-file-plug-fallback-base-leak: sha1_file: release fallback base's memory in unpack_entry()
-rw-r--r--sha1_file.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 6628f06..2ee3c61 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2606,6 +2606,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;
@@ -2632,6 +2633,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;
}
}
@@ -2650,6 +2652,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;
}
@@ -2669,6 +2672,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;