aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorColin Snover2017-01-05 22:44:33 -0600
committerColin Snover2017-01-09 19:34:54 -0600
commit8cce4f1b8c175a52a035e01318a797d4797ecd85 (patch)
tree21ee62e82bdd02308b2bd0ccd8ca8cda18541da7 /engines/sci
parent7567940ba14ef7d2277dea73161383c8d65e9ee6 (diff)
downloadscummvm-rg350-8cce4f1b8c175a52a035e01318a797d4797ecd85.tar.gz
scummvm-rg350-8cce4f1b8c175a52a035e01318a797d4797ecd85.tar.bz2
scummvm-rg350-8cce4f1b8c175a52a035e01318a797d4797ecd85.zip
SCI32: Ignore attempts to free null array reg_ts
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/kernel_tables.h2
-rw-r--r--engines/sci/engine/kstring.cpp4
-rw-r--r--engines/sci/engine/seg_manager.cpp5
3 files changed, 7 insertions, 4 deletions
diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h
index e05348a0cd..c611af4aee 100644
--- a/engines/sci/engine/kernel_tables.h
+++ b/engines/sci/engine/kernel_tables.h
@@ -511,7 +511,7 @@ static const SciKernelMapSubEntry kArray_subops[] = {
{ SIG_SCI32, 1, MAP_CALL(ArrayGetSize), "r", NULL },
{ SIG_SCI32, 2, MAP_CALL(ArrayGetElement), "ri", NULL },
{ SIG_SCI32, 3, MAP_CALL(ArraySetElements), "ri(.*)", kArraySetElements_workarounds },
- { SIG_SCI32, 4, MAP_CALL(ArrayFree), "r", NULL },
+ { SIG_SCI32, 4, MAP_CALL(ArrayFree), "[0r]", NULL },
{ SIG_SCI32, 5, MAP_CALL(ArrayFill), "riii", NULL },
{ SIG_SCI32, 6, MAP_CALL(ArrayCopy), "ririi", NULL },
// there is no subop 7
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index ab1f0210e7..ae91ef088a 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -663,9 +663,7 @@ reg_t kStringGetChar(EngineState *s, int argc, reg_t *argv) {
}
reg_t kStringFree(EngineState *s, int argc, reg_t *argv) {
- if (!argv[0].isNull()) {
- s->_segMan->freeArray(argv[0]);
- }
+ s->_segMan->freeArray(argv[0]);
return s->r_acc;
}
diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp
index 159d3170f8..23d1942dd3 100644
--- a/engines/sci/engine/seg_manager.cpp
+++ b/engines/sci/engine/seg_manager.cpp
@@ -892,6 +892,11 @@ SciArray *SegManager::lookupArray(reg_t addr) {
}
void SegManager::freeArray(reg_t addr) {
+ // SSCI memory manager ignores attempts to free null handles
+ if (addr.isNull()) {
+ return;
+ }
+
if (_heap[addr.getSegment()]->getType() != SEG_TYPE_ARRAY)
error("Attempt to use non-array %04x:%04x as array", PRINT_REG(addr));