vulkan: do not access member of a NULL structure
Check if the structure is NULL before trying to get access to its members. This has been detected by the Undefined Behaviour Sanitizer (UBSan). Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29772>
This commit is contained in:

committed by
Marge Bot

parent
a407285ff2
commit
081555c58b
@@ -161,9 +161,10 @@ vk_object_base_from_u64_handle(uint64_t handle, VkObjectType obj_type)
|
||||
static inline __VkType \
|
||||
__driver_type ## _to_handle(struct __driver_type *_obj) \
|
||||
{ \
|
||||
vk_object_base_assert_valid(&_obj->__base, __VK_TYPE); \
|
||||
if (_obj != NULL) \
|
||||
if (_obj != NULL) { \
|
||||
vk_object_base_assert_valid(&_obj->__base, __VK_TYPE); \
|
||||
_obj->__base.client_visible = true; \
|
||||
} \
|
||||
return (__VkType) _obj; \
|
||||
}
|
||||
|
||||
@@ -201,9 +202,10 @@ vk_object_base_from_u64_handle(uint64_t handle, VkObjectType obj_type)
|
||||
UNUSED static inline __VkType \
|
||||
__driver_type ## _to_handle(struct __driver_type *_obj) \
|
||||
{ \
|
||||
vk_object_base_assert_valid(&_obj->__base, __VK_TYPE); \
|
||||
if (_obj != NULL) \
|
||||
if (_obj != NULL) { \
|
||||
vk_object_base_assert_valid(&_obj->__base, __VK_TYPE); \
|
||||
_obj->__base.client_visible = true; \
|
||||
} \
|
||||
return (__VkType)(uintptr_t) _obj; \
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user