From 796867cd32408aada11fc21323d5ee0ce201ffee Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 8 Jan 2013 23:07:22 +0200 Subject: [PATCH] TOLTECS: Fix script bug #3599964 - "TOLTECS: Crash when entering cave" --- engines/toltecs/script.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/engines/toltecs/script.cpp b/engines/toltecs/script.cpp index f5e3f8481f1..9ea95a2cd1c 100644 --- a/engines/toltecs/script.cpp +++ b/engines/toltecs/script.cpp @@ -252,9 +252,12 @@ void ScriptInterpreter::execOpcode(byte opcode) { // ok _subCode = _code; byte length = readByte(); + if (length == 0) { + warning("Possible script bug detected - opcode length is 0 when calling script function"); + return; + } debug(2, "length = %d", length); uint16 index = readInt16(); - debug(2, "callScriptFunction %d", index); execScriptFunction(index); _code += length - 2; break;