From 1296c1fe8082f45d64fba31092f2bfae303e6f3b Mon Sep 17 00:00:00 2001 From: Stephen Miller Date: Thu, 15 May 2025 21:43:08 -0500 Subject: [PATCH] Move overwrite check to while condition --- src/core/memory.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/core/memory.cpp b/src/core/memory.cpp index ab07147df..1cbb2a8e1 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -378,15 +378,12 @@ int MemoryManager::MapMemory(void** out_addr, VAddr virtual_addr, size_t size, M auto unmap_size = size; // If flag NoOverwrite is provided, don't overwrite mapped VMAs. // When it isn't provided, VMAs can be overwritten regardless of if they're mapped. - auto should_overwrite = False(flags & MemoryMapFlags::NoOverwrite) || !vma.IsMapped(); - while (should_overwrite && unmap_addr < mapped_addr + size && remaining_size < size) { + while ((False(flags & MemoryMapFlags::NoOverwrite) || !vma.IsMapped()) && + unmap_addr < mapped_addr + size && remaining_size < size) { auto unmapped = UnmapBytesFromEntry(unmap_addr, vma, unmap_size); unmap_addr += unmapped; unmap_size -= unmapped; - // Unmap addr should be the address of the next VMA - // if the previous VMA is fully unmapped. vma = FindVMA(unmap_addr)->second; - should_overwrite = False(flags & MemoryMapFlags::NoOverwrite) || !vma.IsMapped(); } vma = FindVMA(mapped_addr)->second;