Commit bd1aa741a4e7b2b83991e7bccbfe55960929af9e

Ben Noordhuis 2011-03-14T00:07:37

git_object_lookup() should also check the type if the object comes from the cache

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/src/object.c b/src/object.c
index fce9915..c432c6d 100644
--- a/src/object.c
+++ b/src/object.c
@@ -276,6 +276,9 @@ int git_object_lookup(git_object **object_out, git_repository *repo, const git_o
 
 	object = git_hashtable_lookup(repo->objects, id);
 	if (object != NULL) {
+		if (type != GIT_OBJ_ANY && type != object->source.raw.type)
+			return GIT_EINVALIDTYPE;
+
 		*object_out = object;
 		object->lru = ++repo->lru_counter;
 		object->can_free = 0;