From: Shawn O. Pearce Date: Wed, 30 May 2007 06:13:14 +0000 (-0400) Subject: Ensure the pack index is opened before access X-Git-Tag: v1.5.3-rc0~171^2~1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b77ffe8a57a0921f58cff22dcf1ed6ae64d89d6a;p=git.git Ensure the pack index is opened before access In this particular location of fsck the index should have already been opened by verify_pack, which is called just before we get here and loop through the object names. However, just in case a future version of that function does not use the index file we'll double-check its open before we access the num_objects field. Better safe now than sorry later. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- diff --git a/builtin-fsck.c b/builtin-fsck.c index cbbcaf011..9959818ce 100644 --- a/builtin-fsck.c +++ b/builtin-fsck.c @@ -668,7 +668,10 @@ int cmd_fsck(int argc, char **argv, const char *prefix) verify_pack(p, 0); for (p = packed_git; p; p = p->next) { - uint32_t i, num = p->num_objects; + uint32_t i, num; + if (open_pack_index(p)) + continue; + num = p->num_objects; for (i = 0; i < num; i++) fsck_sha1(nth_packed_object_sha1(p, i)); }