Add check for an invalid D3D12/Vk object in SetDebugLabel
Fixes a crash found while fuzzing by returning early when SetDebugName
is called with an empty D3D12/Vulkan object or when the device is lost.
Adds tests.
Bug: chromium:1245720
Change-Id: Ie443f690cf5635d017295a13e21c33dd2e97dc46
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63363
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brandon Jones (Intel) <brandon1.jones@intel.com>
diff --git a/src/dawn_native/vulkan/UtilsVulkan.cpp b/src/dawn_native/vulkan/UtilsVulkan.cpp
index eb46180..fd7a4ae 100644
--- a/src/dawn_native/vulkan/UtilsVulkan.cpp
+++ b/src/dawn_native/vulkan/UtilsVulkan.cpp
@@ -170,6 +170,10 @@
uint64_t objectHandle,
const char* prefix,
std::string label) {
+ if (!objectHandle) {
+ return;
+ }
+
if (device->GetGlobalInfo().HasExt(InstanceExt::DebugUtils)) {
VkDebugUtilsObjectNameInfoEXT objectNameInfo;
objectNameInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;