summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitaclaw <140017135+mitaclaw@users.noreply.github.com>2024-09-01 19:35:56 -0700
committermitaclaw <140017135+mitaclaw@users.noreply.github.com>2024-09-01 19:36:21 -0700
commit5a95c5dd14444f60eb7e36b3a941e469e5e638ff (patch)
tree28a9d3f1c763350a413c06b1d307232bf720807c
parent7d08377341da0436ee893ccb92e346c9751e3d6c (diff)
CachedInterpreterEmitter: Fix `std::memcpy` UB
I wasn't aware that even with a size of zero, it's still not safe to pass a nullptr to `std::memcpy`. When `CachedInterpreterEmitter::PoisonCallback` is written, UB is happening.
-rw-r--r--Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreterEmitter.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreterEmitter.cpp b/Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreterEmitter.cpp
index 8422ef9edb..ffd1042594 100644
--- a/Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreterEmitter.cpp
+++ b/Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreterEmitter.cpp
@@ -19,6 +19,8 @@ void CachedInterpreterEmitter::Write(AnyCallback callback, const void* operands,
}
std::memcpy(m_code, &callback, sizeof(callback));
m_code += sizeof(callback);
+ if (size == 0)
+ return;
std::memcpy(m_code, operands, size);
m_code += size;
}