Skip to content

Commit c35dfe8

Browse files
author
Linus Torvalds
committed
Verify that the object type matches for tree/commit objects even before parsing.
The type doesn't come from the parsing, the type also has to match the usage.
1 parent d32987b commit c35dfe8

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct commit *lookup_commit(unsigned char *sha1)
1515
ret->object.type = commit_type;
1616
return ret;
1717
}
18-
if (obj->parsed && obj->type != commit_type) {
18+
if (obj->type != commit_type) {
1919
error("Object %s is a %s, not a commit",
2020
sha1_to_hex(sha1), obj->type);
2121
return NULL;

tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ struct tree *lookup_tree(unsigned char *sha1)
8080
ret->object.type = tree_type;
8181
return ret;
8282
}
83-
if (obj->parsed && obj->type != tree_type) {
83+
if (obj->type != tree_type) {
8484
error("Object %s is a %s, not a tree",
8585
sha1_to_hex(sha1), obj->type);
8686
return NULL;

0 commit comments

Comments
 (0)