Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 1cef4e6

Browse files
committed
Allow null dispatchable objects
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 <[email protected]> Tested-by: Alexis Hétu <[email protected]> Kokoro-Presubmit: kokoro <[email protected]>
1 parent 036614c commit 1cef4e6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Vulkan/VkObject.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ class DispatchableObject
144144

145145
static inline T* Cast(VkT vkObject)
146146
{
147-
return &(reinterpret_cast<DispatchableObject<T, VkT>*>(vkObject)->object);
147+
return (vkObject == VK_NULL_HANDLE) ? nullptr :
148+
&(reinterpret_cast<DispatchableObject<T, VkT>*>(vkObject)->object);
148149
}
149150

150151
operator VkT()

0 commit comments

Comments
 (0)