aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine
diff options
context:
space:
mode:
authorFilippos Karapetis2009-12-28 14:22:11 +0000
committerFilippos Karapetis2009-12-28 14:22:11 +0000
commit2973862488aebfbcdd954701ee1cf5875da5dda1 (patch)
tree42ca9fc186c9d61fa372397a7b4aa295b052534c /engines/sci/engine
parent62c1c2633dbb94a84cffec093e6a2118946ef8c9 (diff)
downloadscummvm-rg350-2973862488aebfbcdd954701ee1cf5875da5dda1.tar.gz
scummvm-rg350-2973862488aebfbcdd954701ee1cf5875da5dda1.tar.bz2
scummvm-rg350-2973862488aebfbcdd954701ee1cf5875da5dda1.zip
Added a workaround for an off-by-one invalid species access bug in the LSL2 demo
svn-id: r46673
Diffstat (limited to 'engines/sci/engine')
-rw-r--r--engines/sci/engine/vm.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index c483da7723..504f70b7ed 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -1591,11 +1591,17 @@ int script_instantiate_sci0(ResourceManager *resMan, SegManager *segMan, int scr
int species;
species = scr->getHeap(addr.offset - SCRIPT_OBJECT_MAGIC_OFFSET + SCRIPT_SPECIES_OFFSET);
if (species < 0 || species >= (int)segMan->_classtable.size()) {
- warning("Invalid species %d(0x%x) not in interval "
- "[0,%d) while instantiating script %d\n",
- species, species, segMan->_classtable.size(),
- script_nr);
- return 0;
+ if (species == (int)segMan->_classtable.size()) {
+ // Happens in the LSL2 demo
+ warning("Applying workaround for an off-by-one invalid species access");
+ segMan->_classtable.resize(segMan->_classtable.size() + 1);
+ } else {
+ warning("Invalid species %d(0x%x) not in interval "
+ "[0,%d) while instantiating script %d\n",
+ species, species, segMan->_classtable.size(),
+ script_nr);
+ return 0;
+ }
}
segMan->_classtable[species].reg = addr;