mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-10-20 09:38:59 +02:00
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.
This commit is contained in:
1 parent
cd3ea81462
commit
d2f7ed3602
1 file changed
+4
-2
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user