Skip to content

Commit

Permalink
vulkan/utils: assert that struct sizes are known
Browse files Browse the repository at this point in the history
Current default is to do various funky types of UB.
  • Loading branch information
haasn committed Feb 20, 2023
1 parent 1ede859 commit 2f48906
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/vulkan/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 2f48906

Please sign in to comment.