From: Nguyễn Thái Ngọc Duy Date: Sat, 21 Sep 2013 13:57:54 GMT Subject: [PATCH 08/17] fixup! pack v4: code to obtain a SHA1 from a sha1ref Message-ID: <1379771883-10278-9-git-send-email-pclouds@gmail.com> In-Reply-To: <1379771883-10278-1-git-send-email-pclouds@gmail.com> Don't die or it'll upset t5303's recovery action by repacking from loose objects Signed-off-by: Nguyễn Thái Ngọc Duy --- packv4-parse.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packv4-parse.c b/packv4-parse.c index e833cd2..88b7aa1 100644 --- a/packv4-parse.c +++ b/packv4-parse.c @@ -18,13 +18,18 @@ const unsigned char *get_sha1ref(struct packed_git *p, { const unsigned char *sha1; + if (!p->sha1_table) + return NULL; + if (!**bufp) { sha1 = *bufp + 1; *bufp += 21; } else { unsigned int index = decode_varint(bufp); - if (index < 1 || index - 1 > p->num_objects) - die("bad index in %s", __func__); + if (index < 1 || index - 1 > p->num_objects) { + error("bad index in get_sha1ref"); + return NULL; + } sha1 = p->sha1_table + (index - 1) * 20; } -- 1.8.2.83.gc99314b