diff options
-rw-r--r-- | engines/sci/engine/kernel_tables.h | 2 | ||||
-rw-r--r-- | engines/sci/engine/kstring.cpp | 4 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.cpp | 5 |
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)); |