Merge pull request #5719 from lioncash/small

64BitAllocator: Avoid overwriting Region[0] in Create64BitAllocatorWithRegions
This commit is contained in:
Ryan Houdek authored and GitHub committed 2026-07-11 19:30:08 -07:00
commit 76b35dfeb0
1 file changed
+5 -5
@@ -623,14 +623,14 @@ fextl::unique_ptr<T> make_alloc_unique(FEXCore::Allocator::MemoryRegion& Base, A
fextl::unique_ptr<Alloc::HostAllocator> Create64BitAllocatorWithRegions(fextl::vector<FEXCore::Allocator::MemoryRegion>& Regions) {
// This is a bit tricky as we can't allocate memory safely except from the Regions provided. Otherwise we might overwrite memory pages we
// don't own. Scan the memory regions and find the smallest one.
FEXCore::Allocator::MemoryRegion& Smallest = Regions[0];
for (auto& it : Regions) {
if (it.Size <= Smallest.Size) {
Smallest = it;
FEXCore::Allocator::MemoryRegion* Smallest = &Regions[0];
for (auto& Region : Regions) {
if (Region.Size <= Smallest->Size) {
Smallest = &Region;
}
}
return make_alloc_unique<OSAllocator_64Bit>(Smallest, Regions);
return make_alloc_unique<OSAllocator_64Bit>(*Smallest, Regions);
}
} // namespace Alloc::OSAllocator