mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-25 11:34:55 +00:00
Swap do-while to while
If we use a do-while loop, we waste time if `aligned_size = 0`. This is also still accurate to FreeBSD behavior, where it returns success if `start == end` during mprotect. This also effectively prevents the memory assert seen in updated versions of RESIDENT EVIL 2 (CUSA09193)
This commit is contained in:
parent
6bdd83684b
commit
5307e9d913
@ -602,7 +602,7 @@ s32 MemoryManager::Protect(VAddr addr, size_t size, MemoryProt prot) {
|
||||
|
||||
auto aligned_addr = Common::AlignDown(addr, 16_KB);
|
||||
auto aligned_size = Common::AlignUp(size + addr - aligned_addr, 16_KB);
|
||||
do {
|
||||
while (protected_bytes < aligned_size) {
|
||||
auto it = FindVMA(aligned_addr + protected_bytes);
|
||||
auto& vma_base = it->second;
|
||||
ASSERT_MSG(vma_base.Contains(addr + protected_bytes, 0), "Address {:#x} is out of bounds",
|
||||
@ -615,7 +615,7 @@ s32 MemoryManager::Protect(VAddr addr, size_t size, MemoryProt prot) {
|
||||
return result;
|
||||
}
|
||||
protected_bytes += result;
|
||||
} while (protected_bytes < aligned_size);
|
||||
}
|
||||
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user