Skip to content

Commit

Permalink
Ensure the pack index is opened before access
Browse files Browse the repository at this point in the history
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 <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Shawn O. Pearce authored and Junio C Hamano committed May 30, 2007
1 parent eaa8677 commit b77ffe8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion builtin-fsck.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit b77ffe8

Please sign in to comment.