diff --git a/include/vk_mem_alloc.h b/include/vk_mem_alloc.h index f6cafb3..bf4dd60 100644 --- a/include/vk_mem_alloc.h +++ b/include/vk_mem_alloc.h @@ -7808,6 +7808,10 @@ bool VmaBlockMetadata_Linear::CreateAllocationRequest( VMA_ASSERT(allocType != VMA_SUBALLOCATION_TYPE_FREE); VMA_ASSERT(pAllocationRequest != VMA_NULL); VMA_HEAVY_ASSERT(Validate()); + + if(allocSize > GetSize()) + return false; + pAllocationRequest->size = allocSize; return upperAddress ? CreateAllocationRequest_UpperAddress( diff --git a/src/Tests.cpp b/src/Tests.cpp index b13e5c8..5eb91c5 100644 --- a/src/Tests.cpp +++ b/src/Tests.cpp @@ -3425,6 +3425,14 @@ static void TestVirtualBlocksAlgorithms() }; std::vector allocations; + // Test too large allocation + { + VmaVirtualAllocationCreateInfo allocCreateInfo = {}; + allocCreateInfo.size = blockCreateInfo.size * 2; + VmaVirtualAllocation alloc; + TEST(vmaVirtualAllocate(block, &allocCreateInfo, &alloc, nullptr) < 0); + } + // Make some allocations for(size_t i = 0; i < 20; ++i) {