OSDN Git Service

Allow null dispatchable objects
authorAlexis Hetu <sugoi@google.com>
Fri, 15 Mar 2019 19:56:01 +0000 (15:56 -0400)
committerAlexis Hétu <sugoi@google.com>
Mon, 18 Mar 2019 14:41:54 +0000 (14:41 +0000)
Because we need to dereference dispatchable objects in order to get
the underlying object, we need to first check for VK_NULL_HANDLE to
avoid crashing.

Bug b/116336664

Change-Id: Ia903dcc6142d5e7f283da8fbef0f43bae3ca243f
Tests: dEQP-VK.api.null_handle.free_command_buffers
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/27388
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

src/Vulkan/VkObject.hpp

index 757d556..8957b00 100644 (file)
@@ -144,7 +144,8 @@ public:
 
        static inline T* Cast(VkT vkObject)
        {
-               return &(reinterpret_cast<DispatchableObject<T, VkT>*>(vkObject)->object);
+               return (vkObject == VK_NULL_HANDLE) ? nullptr :
+                      &(reinterpret_cast<DispatchableObject<T, VkT>*>(vkObject)->object);
        }
 
        operator VkT()