Skip to content

Commit eeed979

Browse files
committed
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
2 parents a116022 + b3ea7dd commit eeed979

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sha1_file.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2952,10 +2952,14 @@ static int sha1_loose_object_info(const unsigned char *sha1,
29522952
} else if ((status = parse_sha1_header_extended(hdr, oi, flags)) < 0)
29532953
status = error("unable to parse %s header", sha1_to_hex(sha1));
29542954

2955-
if (status >= 0 && oi->contentp)
2955+
if (status >= 0 && oi->contentp) {
29562956
*oi->contentp = unpack_sha1_rest(&stream, hdr,
29572957
*oi->sizep, sha1);
2958-
else
2958+
if (!*oi->contentp) {
2959+
git_inflate_end(&stream);
2960+
status = -1;
2961+
}
2962+
} else
29592963
git_inflate_end(&stream);
29602964

29612965
munmap(map, mapsize);

0 commit comments

Comments
 (0)