Fix in VmaBlockMetadata_Linear::CreateAllocationRequest for too large allocations

Fixes #396 - thanks @dm-tesla
This commit is contained in:
Adam Sawicki 2024-02-23 17:28:22 +01:00
parent 9b7687761a
commit f1ab507d00
2 changed files with 12 additions and 0 deletions

View File

@ -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(

View File

@ -3425,6 +3425,14 @@ static void TestVirtualBlocksAlgorithms()
};
std::vector<AllocData> 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)
{