diff options
| author | Mai <mai.iam2048@gmail.com> | 2022-12-31 18:55:11 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-31 18:55:11 +0000 |
| commit | 20ac2cf781b1c514b4eea47e5da4195d95b5bad8 (patch) | |
| tree | 4ada2f692e0b1a05f254817cb2144e5e8b9d5ddf /Source/Core | |
| parent | e31722db1c2d83bd13efe100d646c78592f624f2 (diff) | |
| parent | cf16f490687f3bd96737bb21091ce5f9e6220ba4 (diff) | |
Merge pull request #11375 from JosJuice/mmu-inf-write
PowerPC: Fix theoretically possible infinite loop in WriteToHardware
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Core/PowerPC/MMU.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Source/Core/Core/PowerPC/MMU.cpp b/Source/Core/Core/PowerPC/MMU.cpp index 0b9501ab63..307b6bfcbf 100644 --- a/Source/Core/Core/PowerPC/MMU.cpp +++ b/Source/Core/Core/PowerPC/MMU.cpp @@ -8,6 +8,7 @@ #include <cstring> #include <string> +#include "Common/Align.h" #include "Common/Assert.h" #include "Common/BitUtils.h" #include "Common/CommonTypes.h" @@ -379,7 +380,9 @@ static void WriteToHardware(Memory::MemoryManager& memory, u32 em_address, const const u32 rotated_data = std::rotr(data, ((em_address & 0x3) + size) * 8); - for (u32 addr = em_address & ~0x7; addr < em_address + size; addr += 8) + const u32 start_addr = Common::AlignDown(em_address, 8); + const u32 end_addr = Common::AlignUp(em_address + size, 8); + for (u32 addr = start_addr; addr != end_addr; addr += 8) { WriteToHardware<flag, true>(memory, addr, rotated_data, 4); WriteToHardware<flag, true>(memory, addr + 4, rotated_data, 4); |
