From 2f48906f9cb3cae10c5c000a5d3a2a246c08e368 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Mon, 20 Feb 2023 12:44:55 +0100 Subject: [PATCH] vulkan/utils: assert that struct sizes are known Current default is to do various funky types of UB. --- src/vulkan/utils.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/vulkan/utils.c b/src/vulkan/utils.c index e2d9c109..755f660e 100644 --- a/src/vulkan/utils.c +++ b/src/vulkan/utils.c @@ -146,8 +146,7 @@ void *vk_struct_memdup(void *alloc, const void *pin) const VkBaseInStructure *in = pin; size_t size = vk_struct_size(in->sType); - if (!size) - return NULL; + pl_assert(size); VkBaseOutStructure *out = pl_memdup(alloc, in, size); out->pNext = NULL; @@ -156,10 +155,12 @@ void *vk_struct_memdup(void *alloc, const void *pin) void *vk_chain_memdup(void *alloc, const void *pin) { + if (!pin) + return NULL; + const VkBaseInStructure *in = pin; VkBaseOutStructure *out = vk_struct_memdup(alloc, in); - if (!out) - return NULL; + pl_assert(out); out->pNext = vk_chain_memdup(alloc, in->pNext); return out;