diff options
| author | Lioncash <mathew1800@gmail.com> | 2017-03-23 05:58:16 -0400 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2017-03-23 07:10:21 -0400 |
| commit | a7ec2d3831062b432098786a7ed3fa48d2380fbd (patch) | |
| tree | 7979cc95c9494a36e084eacf48604782a04fab6a /Source/Core | |
| parent | 6a17d87b07dda4b31b76733e6c9dfb72c70444a7 (diff) | |
Arm64Emitter: Get rid of pointer casts in PoisonMemory
The previous code invokes undefined behavior.
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Common/Arm64Emitter.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Source/Core/Common/Arm64Emitter.h b/Source/Core/Common/Arm64Emitter.h index 87d89be9a2..07dc8bc9ba 100644 --- a/Source/Core/Common/Arm64Emitter.h +++ b/Source/Core/Common/Arm64Emitter.h @@ -4,6 +4,7 @@ #pragma once +#include <cstring> #include <functional> #include "Common/ArmCommon.h" @@ -1137,14 +1138,16 @@ class ARM64CodeBlock : public CodeBlock<ARM64XEmitter> private: void PoisonMemory() override { - u32* ptr = (u32*)region; - u32* maxptr = (u32*)(region + region_size); // If our memory isn't a multiple of u32 then this won't write the last remaining bytes with // anything // Less than optimal, but there would be nothing we could do but throw a runtime warning anyway. // AArch64: 0xD4200000 = BRK 0 - while (ptr < maxptr) - *ptr++ = 0xD4200000; + constexpr u32 brk_0 = 0xD4200000; + + for (size_t i = 0; i < region_size; i += sizeof(u32)) + { + std::memcpy(region + i, &brk_0, sizeof(u32)); + } } }; } |
