From ae9a249dfeb7d2d0c57f613cd3fee942887ec3fe Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Mon, 5 Aug 2024 15:44:28 +0300 Subject: [PATCH] vulkan/runtime: allow null/empty debug names VkDebugUtilsObjectNameInfoEXT::pObjectName can be NULL [1] : "Applications may change the name associated with an object simply by calling vkSetDebugUtilsObjectNameEXT again with a new string. If pObjectName is either NULL or an empty string, then any previously set name is removed." The current code will segfault. [1] : https://registry.khronos.org/vulkan/specs/1.3-extensions/html/chap50.html#VkDebugUtilsObjectNameInfoEXT Signed-off-by: Lionel Landwerlin Fixes: 3b361b234a ("vulkan: Implement VK_EXT_debug_utils") Reviewed-by: Faith Ekstrand Part-of: --- src/vulkan/runtime/vk_debug_utils.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/vulkan/runtime/vk_debug_utils.c b/src/vulkan/runtime/vk_debug_utils.c index 2c083ab8937..556f3de1afd 100644 --- a/src/vulkan/runtime/vk_debug_utils.c +++ b/src/vulkan/runtime/vk_debug_utils.c @@ -302,10 +302,12 @@ vk_common_SetDebugUtilsObjectNameEXT( vk_free(alloc, object->object_name); object->object_name = NULL; } - object->object_name = vk_strdup(alloc, pNameInfo->pObjectName, - VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); - if (!object->object_name) - return VK_ERROR_OUT_OF_HOST_MEMORY; + if (pNameInfo->pObjectName != NULL) { + object->object_name = vk_strdup(alloc, pNameInfo->pObjectName, + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); + if (!object->object_name) + return VK_ERROR_OUT_OF_HOST_MEMORY; + } return VK_SUCCESS; }