From: Junio C Hamano Date: Wed, 18 Oct 2017 05:19:14 +0000 (+0900) Subject: Merge branch 'jk/sha1-loose-object-info-fix' into maint X-Git-Tag: v2.15.0-rc2~5^2~6 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/eeed979e6a13b60667c856dc3418a14f67607875?ds=inline;hp=-c 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 --- eeed979e6a13b60667c856dc3418a14f67607875 diff --combined sha1_file.c index 9008d6aa7b,8548d29d88..5911364a81 --- a/sha1_file.c +++ b/sha1_file.c @@@ -2761,6 -2761,7 +2761,6 @@@ off_t find_pack_entry_one(const unsigne const uint32_t *level1_ofs = p->index_data; const unsigned char *index = p->index_data; unsigned hi, lo, stride; - static int use_lookup = -1; static int debug_lookup = -1; if (debug_lookup < 0) @@@ -2790,6 -2791,16 +2790,6 @@@ printf("%02x%02x%02x... lo %u hi %u nr %"PRIu32"\n", sha1[0], sha1[1], sha1[2], lo, hi, p->num_objects); - if (use_lookup < 0) - use_lookup = !!getenv("GIT_USE_LOOKUP"); - if (use_lookup) { - int pos = sha1_entry_pos(index, stride, 0, - lo, hi, p->num_objects, sha1); - if (pos < 0) - return 0; - return nth_packed_object_offset(p, pos); - } - while (lo < hi) { unsigned mi = (lo + hi) / 2; int cmp = hashcmp(index + mi * stride, sha1); @@@ -2952,10 -2963,14 +2952,14 @@@ static int sha1_loose_object_info(cons } 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);