From 8aa2013a2d5168338cae888a4c0a766cb8457240 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Sun, 31 Jan 2021 11:50:34 +0000 Subject: [PATCH] Arm64Emitter: Add additional assertions to BFI/UBFIZ --- Source/Core/Common/Arm64Emitter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Common/Arm64Emitter.cpp b/Source/Core/Common/Arm64Emitter.cpp index cad26bbb4f..c3cb492a5f 100644 --- a/Source/Core/Common/Arm64Emitter.cpp +++ b/Source/Core/Common/Arm64Emitter.cpp @@ -1658,7 +1658,7 @@ void ARM64XEmitter::UBFM(ARM64Reg Rd, ARM64Reg Rn, u32 immr, u32 imms) void ARM64XEmitter::BFI(ARM64Reg Rd, ARM64Reg Rn, u32 lsb, u32 width) { u32 size = Is64Bit(Rn) ? 64 : 32; - ASSERT_MSG(DYNA_REC, (lsb + width) <= size, + ASSERT_MSG(DYNA_REC, lsb < size && width >= 1 && width <= size - lsb, "%s passed lsb %d and width %d which is greater than the register size!", __func__, lsb, width); BFM(Rd, Rn, (size - lsb) % size, width - 1); @@ -1674,7 +1674,7 @@ void ARM64XEmitter::BFXIL(ARM64Reg Rd, ARM64Reg Rn, u32 lsb, u32 width) void ARM64XEmitter::UBFIZ(ARM64Reg Rd, ARM64Reg Rn, u32 lsb, u32 width) { u32 size = Is64Bit(Rn) ? 64 : 32; - ASSERT_MSG(DYNA_REC, (lsb + width) <= size, + ASSERT_MSG(DYNA_REC, lsb < size && width >= 1 && width <= size - lsb, "%s passed lsb %d and width %d which is greater than the register size!", __func__, lsb, width); UBFM(Rd, Rn, (size - lsb) % size, width - 1);