From 5b4eb65e68960945dd43dc286069f94c0784b153 Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Sun, 4 Oct 2015 13:34:37 +0100 Subject: [PATCH] =?UTF-8?q?eeInt:=20Fix=20logically=20dead=20code=20in=20P?= =?UTF-8?q?MFLH.=20-Coverity=20CID=20146817:=20In=20R5900::=E2=80=8BInterp?= =?UTF-8?q?reter::=E2=80=8BOpcodeImpl::=E2=80=8BMMI::=E2=80=8BPMFHL():=20C?= =?UTF-8?q?ode=20can=20never=20be=20reached=20because=20of=20a=20logical?= =?UTF-8?q?=20contradiction=20(CWE-561)=20-This=20code=20is=20used=20by=20?= =?UTF-8?q?both=20the=20Interpreter=20and=20Recompiler,=20however=20it=20w?= =?UTF-8?q?as=20probably=20never=20checked=20because=20nothing=20much=20us?= =?UTF-8?q?es=20it.=20Out=20of=20248=20games,=20it=20was=20called=200=20ti?= =?UTF-8?q?mes.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pcsx2/MMI.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pcsx2/MMI.cpp b/pcsx2/MMI.cpp index df28a2e8ee..a20239239f 100644 --- a/pcsx2/MMI.cpp +++ b/pcsx2/MMI.cpp @@ -183,18 +183,20 @@ void PMFHL() { case 0x02: // SLW { s64 TempS64 = ((u64)cpuRegs.HI.UL[0] << 32) | (u64)cpuRegs.LO.UL[0]; + if (TempS64 >= 0x000000007fffffffLL) { cpuRegs.GPR.r[_Rd_].UD[0] = 0x000000007fffffffLL; - } else if (TempS64 <= 0xffffffff80000000LL) { + } else if (TempS64 <= -0x80000000LL) { cpuRegs.GPR.r[_Rd_].UD[0] = 0xffffffff80000000LL; } else { cpuRegs.GPR.r[_Rd_].UD[0] = (s64)cpuRegs.LO.SL[0]; } TempS64 = ((u64)cpuRegs.HI.UL[2] << 32) | (u64)cpuRegs.LO.UL[2]; + if (TempS64 >= 0x000000007fffffffLL) { cpuRegs.GPR.r[_Rd_].UD[1] = 0x000000007fffffffLL; - } else if (TempS64 <= 0xffffffff80000000LL) { + } else if (TempS64 <= -0x80000000LL) { cpuRegs.GPR.r[_Rd_].UD[1] = 0xffffffff80000000LL; } else { cpuRegs.GPR.r[_Rd_].UD[1] = (s64)cpuRegs.LO.SL[2];