From c17685646e9350a3ec3525f504018a2455894eb7 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sat, 30 Jan 2021 12:01:34 +0000 Subject: [PATCH] Fix left shift of negative value in MIPSCodeUtils Fixes a benign UBSAN error to improve the signal-to-noise ratio of UBSAN errors. Fixes #14015 --- Core/MIPS/MIPSCodeUtils.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/MIPS/MIPSCodeUtils.cpp b/Core/MIPS/MIPSCodeUtils.cpp index ce91b2199c..fd83603f49 100644 --- a/Core/MIPS/MIPSCodeUtils.cpp +++ b/Core/MIPS/MIPSCodeUtils.cpp @@ -55,7 +55,7 @@ namespace MIPSCodeUtils MIPSInfo info = MIPSGetInfo(op); if (info & IS_CONDBRANCH) { - return addr + 4 + ((signed short)(op&0xFFFF)<<2); + return addr + 4 + ((signed short)((op&0xFFFF)<<2)); } else return INVALIDTARGET; @@ -77,7 +77,7 @@ namespace MIPSCodeUtils MIPSInfo info = MIPSGetInfo(op); if ((info & IS_CONDBRANCH) && !(info & OUT_RA)) { - return addr + 4 + ((signed short)(op&0xFFFF)<<2); + return addr + 4 + ((signed short)((op&0xFFFF)<<2)); } else return INVALIDTARGET; @@ -125,7 +125,7 @@ namespace MIPSCodeUtils } if (sure && takeBranch) - return addr + 4 + ((signed short)(op&0xFFFF)<<2); + return addr + 4 + ((signed short)((op&0xFFFF)<<2)); else if (sure && !takeBranch) return addr + 8; else