summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-10-18 05:19:14 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-10-18 05:19:14 (GMT)
commiteeed979e6a13b60667c856dc3418a14f67607875 (patch)
tree9802c59da024ca04ba0dfe1f41a47a70226b8351 /sha1_file.c
parenta116022e03d3ef6b402658a4f41a4840c8463f36 (diff)
parentb3ea7dd32d6f8dc117b782ec5ca54ef8f65280c9 (diff)
downloadgit-eeed979e6a13b60667c856dc3418a14f67607875.zip
git-eeed979e6a13b60667c856dc3418a14f67607875.tar.gz
git-eeed979e6a13b60667c856dc3418a14f67607875.tar.bz2
Merge branch 'jk/sha1-loose-object-info-fix' into maint
Leakfix and futureproofing. * jk/sha1-loose-object-info-fix: sha1_loose_object_info: handle errors from unpack_sha1_rest
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 9008d6a..5911364 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2952,10 +2952,14 @@ static int sha1_loose_object_info(const unsigned char *sha1,
} else if ((status = parse_sha1_header_extended(hdr, oi, flags)) < 0)
status = error("unable to parse %s header", sha1_to_hex(sha1));
- if (status >= 0 && oi->contentp)
+ if (status >= 0 && oi->contentp) {
*oi->contentp = unpack_sha1_rest(&stream, hdr,
*oi->sizep, sha1);
- else
+ if (!*oi->contentp) {
+ git_inflate_end(&stream);
+ status = -1;
+ }
+ } else
git_inflate_end(&stream);
munmap(map, mapsize);