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>
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()