Skip to content

Commit 92d4c85

Browse files
author
Linus Torvalds
committed
fsck-cache: fix SIGSEGV on bad tag object
fsck_tag() failes to notice that the parsing of the tag may have failed in the parse_object() call on the object that it is tagging. Noticed by Junio. Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 54c26fb commit 92d4c85

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

fsck-cache.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,17 @@ static int fsck_commit(struct commit *commit)
133133

134134
static int fsck_tag(struct tag *tag)
135135
{
136+
struct object *tagged = tag->tagged;
137+
138+
if (!tagged) {
139+
printf("bad object in tag %s\n", sha1_to_hex(tag->object.sha1));
140+
return -1;
141+
}
136142
if (!show_tags)
137143
return 0;
138144

139-
printf("tagged %s %s",
140-
tag->tagged->type,
141-
sha1_to_hex(tag->tagged->sha1));
142-
printf(" (%s) in %s\n",
143-
tag->tag, sha1_to_hex(tag->object.sha1));
145+
printf("tagged %s %s", tagged->type, sha1_to_hex(tagged->sha1));
146+
printf(" (%s) in %s\n", tag->tag, sha1_to_hex(tag->object.sha1));
144147
return 0;
145148
}
146149

0 commit comments

Comments
 (0)