Skip to content

Commit

Permalink
Fix left shift of negative value in MIPSCodeUtils
Browse files Browse the repository at this point in the history
Fixes a benign UBSAN error to improve the signal-to-noise ratio of
UBSAN errors.

Fixes hrydgard#14015
  • Loading branch information
glebm committed Jan 30, 2021
1 parent c251d69 commit c176856
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Core/MIPS/MIPSCodeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c176856

Please sign in to comment.