diff options
| author | Junio C Hamano <gitster@pobox.com> | 2017-03-21 15:03:27 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2017-03-21 15:03:27 -0700 |
| commit | e36e28e6971e9b9975d46485dfbfa5cc3fbd41ed (patch) | |
| tree | dff2ebdf49f15b678227088b38edf89455b7c2de | |
| parent | Merge branch 'ss/remote-bzr-hg-placeholder-wo-python' into maint (diff) | |
| parent | sha1_file: release fallback base's memory in unpack_entry() (diff) | |
| download | git-e36e28e6971e9b9975d46485dfbfa5cc3fbd41ed.tar.gz git-e36e28e6971e9b9975d46485dfbfa5cc3fbd41ed.zip | |
Merge branch 'rs/sha1-file-plug-fallback-base-leak' into maint
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.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/sha1_file.c b/sha1_file.c index ec957db5e1..8ce80d4481 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -2532,6 +2532,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; @@ -2558,6 +2559,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; } } @@ -2576,6 +2578,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; } @@ -2595,6 +2598,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; |
