From 5e5ed07b4140b98d2bee9128ad096cfae6c21f8b Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Sun, 2 Nov 2014 19:12:21 -0800 Subject: [PATCH] MemArena: Fix the calculation of position in SHM The code to calculate the offsets into the SHM file wasn't properly respecting the skip flags, causing it to calculate offsets beyond the end of the SHM file. --- Source/Core/Common/MemArena.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/Core/Common/MemArena.cpp b/Source/Core/Common/MemArena.cpp index 119549f06d..15de0c37b9 100644 --- a/Source/Core/Common/MemArena.cpp +++ b/Source/Core/Common/MemArena.cpp @@ -176,15 +176,17 @@ static bool Memory_TryBase(u8 *base, MemoryView *views, int num_views, u32 flags // We just mimic the popular BAT setup. u32 shm_position = 0; - // Zero all the pointers to be sure. for (int i = 0; i < num_views; i++) { + // Zero all the pointers to be sure. views[i].mapped_ptr = nullptr; - if (!(views[i].flags & MV_MIRROR_PREVIOUS) && i > 0) - shm_position += views[i - 1].size; + SKIP(flags, views[i].flags); views[i].shm_position = shm_position; + + if (!(views[i].flags & MV_MIRROR_PREVIOUS)) + shm_position += views[i].size; } int i;