From 6a9d36608f7191fb110a6c6d19fe99cb995feac2 Mon Sep 17 00:00:00 2001 From: Vitor K Date: Sat, 1 Oct 2022 07:37:27 -0300 Subject: [PATCH] Allow GetPhysicalRef to hold a past-the-end offset (#6141) Games will sometimes use these when representing open right bounds and so disallowing it caused regressions, with a notable example being when MemoryFill is called to the end of vram, causing an "invalid end address" error. This had been noted on a comment in GetPhysicalRef prior to the regression. --- src/common/memory_ref.h | 2 +- src/core/memory.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/memory_ref.h b/src/common/memory_ref.h index 0a50c7be9..77a118ade 100644 --- a/src/common/memory_ref.h +++ b/src/common/memory_ref.h @@ -77,7 +77,7 @@ public: } MemoryRef(std::shared_ptr backing_mem_, u64 offset_) : backing_mem(std::move(backing_mem_)), offset(offset_) { - ASSERT(offset < backing_mem->GetSize()); + ASSERT(offset <= backing_mem->GetSize()); Init(); } explicit operator bool() const { diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 9f78242fc..178e5383a 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -496,7 +496,7 @@ MemoryRef MemorySystem::GetPhysicalRef(PAddr address) const { default: UNREACHABLE(); } - if (offset_into_region >= target_mem->GetSize()) { + if (offset_into_region > target_mem->GetSize()) { return {nullptr}; }