From 39663a14095f32d33f1372e2343a30eb3ceccae6 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 30 Jan 2013 23:41:34 -0800 Subject: [PATCH] Check RET isn't hit right away for safety. --- GPU/GLES/DisplayListInterpreter.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/GPU/GLES/DisplayListInterpreter.cpp b/GPU/GLES/DisplayListInterpreter.cpp index 6746403bbb..dd69eabcb1 100644 --- a/GPU/GLES/DisplayListInterpreter.cpp +++ b/GPU/GLES/DisplayListInterpreter.cpp @@ -414,12 +414,15 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff) { case GE_CMD_RET: { - u32 target = (currentList->pc & 0xF0000000) | (stack[--stackptr] & 0x0FFFFFFF); - currentList->pc = target - 4; - if (!Memory::IsValidAddress(currentList->pc)) - { - ERROR_LOG(G3D, "Invalid DL PC %08x on return", currentList->pc); - finished = true; + if (stackptr == 0) { + ERROR_LOG(G3D, "RET: Stack empty!"); + } else { + u32 target = (currentList->pc & 0xF0000000) | (stack[--stackptr] & 0x0FFFFFFF); + currentList->pc = target - 4; + if (!Memory::IsValidAddress(currentList->pc)) { + ERROR_LOG(G3D, "Invalid DL PC %08x on return", currentList->pc); + finished = true; + } } } break;