From 3e5d8280fadb8cf98a181c65c08d0c43be7af912 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Tue, 29 Dec 2009 21:37:26 +0000 Subject: SCI: dont crash when scripts are trying to access invalid memory (fixes intro of lb2cd) svn-id: r46718 --- engines/sci/engine/segment.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; } -- cgit v1.2.3