]> git.proxmox.com Git - libgit2.git/commitdiff
git_object_lookup() should also check the type if the object comes from the cache
authorBen Noordhuis <info@bnoordhuis.nl>
Sun, 13 Mar 2011 23:07:37 +0000 (00:07 +0100)
committerVicent Marti <tanoku@gmail.com>
Tue, 15 Mar 2011 00:56:19 +0000 (02:56 +0200)
src/object.c

index fce99153bdc9c0b36365b6bb7ef5a27ed409a93a..c432c6da0e5bca50e33b845977a78a21e7b0d3da 100644 (file)
@@ -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;