aboutsummaryrefslogtreecommitdiff
path: root/engines/director
diff options
context:
space:
mode:
authorEugene Sandulenko2019-11-29 18:38:46 +0100
committerEugene Sandulenko2019-11-29 18:38:46 +0100
commitb2233f83e2c2d850cb42f7a3466a8c4391d20693 (patch)
tree9f1c973ca1518144c80ce96a6612f0a362b277bc /engines/director
parent07ad932262f50da92ca0b0a76b36f0b23f484f0d (diff)
downloadscummvm-rg350-b2233f83e2c2d850cb42f7a3466a8c4391d20693.tar.gz
scummvm-rg350-b2233f83e2c2d850cb42f7a3466a8c4391d20693.tar.bz2
scummvm-rg350-b2233f83e2c2d850cb42f7a3466a8c4391d20693.zip
DIRECTOR: LINGO: Add sanity checks to script execution
Diffstat (limited to 'engines/director')
-rw-r--r--engines/director/lingo/lingo-codegen.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/engines/director/lingo/lingo-codegen.cpp b/engines/director/lingo/lingo-codegen.cpp
index 07f733f9ca..2be88487d7 100644
--- a/engines/director/lingo/lingo-codegen.cpp
+++ b/engines/director/lingo/lingo-codegen.cpp
@@ -53,7 +53,7 @@
namespace Director {
void Lingo::execute(uint pc) {
- for(_pc = pc; (*_currentScript)[_pc] != STOP && !_returning;) {
+ for (_pc = pc; !_returning && (*_currentScript)[_pc] != STOP;) {
Common::String instr = decodeInstruction(_pc);
if (debugChannelSet(5, kDebugLingoExec))
@@ -66,6 +66,11 @@ void Lingo::execute(uint pc) {
if (debugChannelSet(5, kDebugLingoExec))
printStack("Stack after: ");
+
+ if (_pc >= (*_currentScript).size()) {
+ warning("Lingo::execute(): Bad PC (%d)", _pc);
+ break;
+ }
}
}