diff options
| author | JosJuice <josjuice@gmail.com> | 2026-08-09 19:42:59 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2026-08-09 20:20:53 +0200 |
| commit | d2f7ed3602be867051639dcee2c660a1879d0b97 (patch) | |
| tree | 145eb72e8201983c407eea78999c27cb146835f7 /Source/Core | |
| parent | cd3ea814628d36939340ef67a6edb19e6b094279 (diff) | |
Common: Fix LazyMemoryRegion::EnsureMemoryPagesWritable
If (offset + size) % BLOCK_SIZE was smaller than offset % BLOCK_SIZE,
the loop terminated one iteration too early, potentially leaving a block
read-only.
None of the existing users of LazyMemoryRegion could trigger this bug,
because they never made EnsureMemoryPagesWritable calls that straddled
across two blocks, but the next commit will add a new use that does.
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Common/MemArena.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Source/Core/Common/MemArena.h b/Source/Core/Common/MemArena.h index 1a3093cc4d..654b13b9a1 100644 --- a/Source/Core/Common/MemArena.h +++ b/Source/Core/Common/MemArena.h @@ -11,6 +11,7 @@ #include <mach/mach.h> #endif +#include "Common/Align.h" #include "Common/CommonTypes.h" #include "Common/DynamicLibrary.h" @@ -207,8 +208,9 @@ public: void EnsureMemoryPagesWritable(size_t offset, size_t size) { #ifdef _WIN32 - for (const auto end_offset = offset + size; offset < end_offset; offset += BLOCK_SIZE) - EnsureMemoryPageWritable(offset); + const size_t end_offset = offset + size; + for (size_t i = Common::AlignDown(offset, BLOCK_SIZE); i < end_offset; i += BLOCK_SIZE) + EnsureMemoryPageWritable(i); #endif } |
