Properly protect the HLE instructions against corrupted memory. (#189)
[pcsx_rearmed.git] / libpcsxcore / psxinterpreter.c
index cf3de79..fa454e1 100644 (file)
@@ -842,7 +842,13 @@ void psxBASIC(struct psxCP2Regs *regs) {
 
 void psxHLE() {
 //     psxHLEt[psxRegs.code & 0xffff]();
-       psxHLEt[psxRegs.code & 0x07]();         // HDHOSHY experimental patch
+//     psxHLEt[psxRegs.code & 0x07]();         // HDHOSHY experimental patch
+    uint32_t hleCode = psxRegs.code & 0x03ffffff;
+    if (hleCode >= (sizeof(psxHLEt) / sizeof(psxHLEt[0]))) {
+        psxNULL();
+    } else {
+        psxHLEt[hleCode]();
+    }
 }
 
 void (*psxBSC[64])() = {