From c2df9d8d0769ead6bfd90346fca88c286cf362e1 Mon Sep 17 00:00:00 2001 From: Aitor Camacho Date: Tue, 27 Oct 2026 14:07:43 -0600 Subject: [PATCH] Force size 0 allocations to be size 1 allocations to avoid misreporting OOM calloc or custom Vulkan host allocators can return null for size 0 allocations. Certain checks in the loader will report OOM if the pointer returned by the allocation calls is null even if the execution can continue without any issues. Fix this issue by requesting 1 byte instead of 0. --- loader/allocation.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/loader/allocation.c b/loader/allocation.c index 4a82c4dde..59d9ff62b 100644 --- a/loader/allocation.c +++ b/loader/allocation.c @@ -33,6 +33,11 @@ void *loader_calloc(const VkAllocationCallbacks *pAllocator, size_t size, VkSystemAllocationScope allocation_scope) { void *pMemory = NULL; + + // Requesting a size 0 allocation to either calloc or custom Vulkan allocators is unspecified. This means we could get NULL as + // the return value, which can end up as an OOM error from the loader when execution can continue without issues. + if (size == 0) size = 1; + #if (DEBUG_DISABLE_APP_ALLOCATORS == 1) { #else