diff --git a/pcsx2/x86/iCore.cpp b/pcsx2/x86/iCore.cpp index 8b6816026b..eb3b44a1a9 100644 --- a/pcsx2/x86/iCore.cpp +++ b/pcsx2/x86/iCore.cpp @@ -144,6 +144,9 @@ int _allocTempXMMreg(XMMSSEType type, int xmmreg) { else _freeXMMreg(xmmreg); + if (xmmreg == -1) + return -1; + xmmregs[xmmreg].inuse = 1; xmmregs[xmmreg].type = XMMTYPE_TEMP; xmmregs[xmmreg].needed = 1; @@ -191,6 +194,9 @@ int _allocVFtoXMMreg(VURegs *VU, int xmmreg, int vfreg, int mode) { else _freeXMMreg(xmmreg); + if (xmmreg == -1) + return -1; + g_xmmtypes[xmmreg] = XMMT_FPS; xmmregs[xmmreg].inuse = 1; xmmregs[xmmreg].type = XMMTYPE_VFREG; @@ -273,6 +279,9 @@ int _allocACCtoXMMreg(VURegs *VU, int xmmreg, int mode) { else _freeXMMreg(xmmreg); + if (xmmreg == -1) + return -1; + g_xmmtypes[xmmreg] = XMMT_FPS; xmmregs[xmmreg].inuse = 1; xmmregs[xmmreg].type = XMMTYPE_ACC; @@ -314,6 +323,7 @@ int _allocFPtoXMMreg(int xmmreg, int fpreg, int mode) { } if (xmmreg == -1) xmmreg = _getFreeXMMreg(); + if (xmmreg == -1) return -1; g_xmmtypes[xmmreg] = XMMT_FPS; xmmregs[xmmreg].inuse = 1; @@ -379,6 +389,7 @@ int _allocGPRtoXMMreg(int xmmreg, int gprreg, int mode) } if (xmmreg == -1) xmmreg = _getFreeXMMreg(); + if (xmmreg == -1) return -1; g_xmmtypes[xmmreg] = XMMT_INT; xmmregs[xmmreg].inuse = 1; @@ -455,9 +466,10 @@ int _allocFPACCtoXMMreg(int xmmreg, int mode) return i; } - if (xmmreg == -1) { + if (xmmreg == -1) xmmreg = _getFreeXMMreg(); - } + if (xmmreg == -1) + return -1; g_xmmtypes[xmmreg] = XMMT_FPS; xmmregs[xmmreg].inuse = 1; diff --git a/pcsx2/x86/ix86-32/iCore-32.cpp b/pcsx2/x86/ix86-32/iCore-32.cpp index 2170b53324..fbb44d5fa7 100644 --- a/pcsx2/x86/ix86-32/iCore-32.cpp +++ b/pcsx2/x86/ix86-32/iCore-32.cpp @@ -311,6 +311,9 @@ int _allocX86reg(int x86reg, int type, int reg, int mode) else _freeX86reg(x86reg); + if (x86reg == -1) + return -1; + x86regs[x86reg].type = type; x86regs[x86reg].reg = reg; x86regs[x86reg].mode = mode; @@ -584,6 +587,7 @@ int _allocMMXreg(int mmxreg, int reg, int mode) } if (mmxreg == -1) mmxreg = _getFreeMMXreg(); + if (mmxreg == -1) return -1; mmxregs[mmxreg].inuse = 1; mmxregs[mmxreg].reg = reg;