aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Kiewitz2009-12-29 21:37:26 +0000
committerMartin Kiewitz2009-12-29 21:37:26 +0000
commit3e5d8280fadb8cf98a181c65c08d0c43be7af912 (patch)
tree927dc5505727cc80c1b616e34e2eefc8add8672b
parentbca313c6fc85d54dd6a7d969a4b82e55bf863f4b (diff)
downloadscummvm-rg350-3e5d8280fadb8cf98a181c65c08d0c43be7af912.tar.gz
scummvm-rg350-3e5d8280fadb8cf98a181c65c08d0c43be7af912.tar.bz2
scummvm-rg350-3e5d8280fadb8cf98a181c65c08d0c43be7af912.zip
SCI: dont crash when scripts are trying to access invalid memory (fixes intro of lb2cd)
svn-id: r46718
-rw-r--r--engines/sci/engine/segment.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/engines/sci/engine/segment.cpp b/engines/sci/engine/segment.cpp
index 9f934a3f1d..991a56a8cf 100644
--- a/engines/sci/engine/segment.cpp
+++ b/engines/sci/engine/segment.cpp
@@ -264,7 +264,10 @@ SegmentRef LocalVariables::dereference(reg_t pointer) {
SegmentRef ret;
ret.isRaw = false; // reg_t based data!
ret.maxSize = (_locals.size() - pointer.offset/2) * 2;
- ret.raw = (byte *)&_locals[pointer.offset/2];
+ if (ret.maxSize > 0)
+ ret.raw = (byte *)&_locals[pointer.offset/2];
+ else
+ warning("LocalVariables::dereference: Offset at end or out of bounds %04x:%04x", PRINT_REG(pointer));
return ret;
}