From 4aa3ec63deae1dab4b04b7b7482472423e93119d Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Sat, 19 May 2007 21:16:31 +0000 Subject: when reading a string from a script, skip the '\0' trailing char (less opcode '0' executions...) svn-id: r26880 --- engines/cine/script.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/cine/script.cpp b/engines/cine/script.cpp index 3b2510c2e7..738ade2834 100644 --- a/engines/cine/script.cpp +++ b/engines/cine/script.cpp @@ -448,7 +448,7 @@ uint16 getNextWord() { const char *getNextString() { const char *val = (const char *)(_currentScriptPtr + _currentPosition); - _currentPosition += strlen(val); + _currentPosition += strlen(val) + 1; return val; } @@ -562,7 +562,7 @@ uint16 computeScriptStackSub(bool computeAllLabels, byte *scriptPtr, int16 *stac while (position < scriptSize) { uint8 opcode = scriptPtr[position]; position++; - if (opcode == 0) { + if (opcode == 0 || opcode > _numOpcodes) { continue; } if (!_opcodeTable[opcode - 1].args) { @@ -600,9 +600,7 @@ uint16 computeScriptStackSub(bool computeAllLabels, byte *scriptPtr, int16 *stac } break; case 's': // string - do { - position++; - } while (scriptPtr[position] != 0); + while (scriptPtr[position++] != 0); break; case 'x': // exit script return position; -- cgit v1.2.3