From cfa43f64bf57f3afb2c07ed72d3b79f2326d877b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 17 Sep 2015 09:35:11 -0400 Subject: [PATCH] x64Emitter: Remove pointer cast No more ubsan asserts in the JIT and x64 emitter code paths when running starfield. --- Source/Core/Common/x64Emitter.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Core/Common/x64Emitter.cpp b/Source/Core/Common/x64Emitter.cpp index f2763d83a8..6cc779b80a 100644 --- a/Source/Core/Common/x64Emitter.cpp +++ b/Source/Core/Common/x64Emitter.cpp @@ -494,7 +494,9 @@ void XEmitter::SetJumpTarget(const FixupBranch& branch) { s64 distance = (s64)(code - branch.ptr); _assert_msg_(DYNA_REC, distance >= -0x80000000LL && distance < 0x80000000LL, "Jump target too far away, needs indirect register"); - ((s32*)branch.ptr)[-1] = (s32)distance; + + s32 valid_distance = static_cast(distance); + std::memcpy(&branch.ptr[-4], &valid_distance, sizeof(s32)); } }