From d43ea187b223a2639308ee7fd6e86a5beca2f9ad Mon Sep 17 00:00:00 2001 From: IndecisiveTurtle <47210458+raphaelthegreat@users.noreply.github.com> Date: Sun, 10 Nov 2024 20:08:21 +0200 Subject: [PATCH] address_space: Fix unmap of region surrounded by placeholders --- src/core/address_space.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/address_space.cpp b/src/core/address_space.cpp index b7547867..224c762a 100644 --- a/src/core/address_space.cpp +++ b/src/core/address_space.cpp @@ -1,7 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include +#include #include "common/alignment.h" #include "common/arch.h" #include "common/assert.h" @@ -277,13 +277,14 @@ struct AddressSpace::Impl { } it_prev->second.size = total_size; - it = regions.erase(it); + regions.erase(it); + it = it_prev; } // Check if a placeholder exists right after us. auto it_next = std::next(it); if (it_next != regions.end() && !it_next->second.is_mapped) { - const size_t total_size = size + it_next->second.size; + const size_t total_size = it->second.size + it_next->second.size; if (!VirtualFreeEx(process, LPVOID(it->first), total_size, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS)) { UNREACHABLE_MSG("Region coalescing failed: {}", Common::GetLastErrorMsg()); }