server: Check for STATUS_OBJECT_TYPE_MISMATCH before STATUS_ACCESS_DENIED in get_handle_obj.
diff --git a/server/handle.c b/server/handle.c
index 9d91f16..c7cd417 100644
--- a/server/handle.c
+++ b/server/handle.c
@@ -403,14 +403,19 @@
             set_error( STATUS_INVALID_HANDLE );
             return NULL;
         }
+        obj = entry->ptr;
+        if (ops && (obj->ops != ops))
+        {
+            set_error( STATUS_OBJECT_TYPE_MISMATCH );  /* not the right type */
+            return NULL;
+        }
         if ((entry->access & access) != access)
         {
             set_error( STATUS_ACCESS_DENIED );
             return NULL;
         }
-        obj = entry->ptr;
     }
-    if (ops && (obj->ops != ops))
+    else if (ops && (obj->ops != ops))
     {
         set_error( STATUS_OBJECT_TYPE_MISMATCH );  /* not the right type */
         return NULL;