Skip to content

Commit 40abbe4

Browse files
committed
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
2 parents 4af0500 + b3ea7dd commit 40abbe4

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
@@ -1124,10 +1124,14 @@ static int sha1_loose_object_info(const unsigned char *sha1,
11241124
} else if ((status = parse_sha1_header_extended(hdr, oi, flags)) < 0)
11251125
status = error("unable to parse %s header", sha1_to_hex(sha1));
11261126

1127-
if (status >= 0 && oi->contentp)
1127+
if (status >= 0 && oi->contentp) {
11281128
*oi->contentp = unpack_sha1_rest(&stream, hdr,
11291129
*oi->sizep, sha1);
1130-
else
1130+
if (!*oi->contentp) {
1131+
git_inflate_end(&stream);
1132+
status = -1;
1133+
}
1134+
} else
11311135
git_inflate_end(&stream);
11321136

11331137
munmap(map, mapsize);

0 commit comments

Comments
 (0)