summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-10-11 05:52:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-10-11 05:52:22 (GMT)
commit40abbe4306e65e604ea5c5bf2ff37f010db5cc81 (patch)
tree38af283c569cf7949622b2eb4c8484f5adec9c09 /sha1_file.c
parent4af0500a51ccda64dc9b3d462dd15e1435077735 (diff)
parentb3ea7dd32d6f8dc117b782ec5ca54ef8f65280c9 (diff)
downloadgit-40abbe4306e65e604ea5c5bf2ff37f010db5cc81.zip
git-40abbe4306e65e604ea5c5bf2ff37f010db5cc81.tar.gz
git-40abbe4306e65e604ea5c5bf2ff37f010db5cc81.tar.bz2
Merge branch 'jk/sha1-loose-object-info-fix'
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 09ad64c..10c3a00 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1124,10 +1124,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);