From 3d1f1a3a21edd66f20f8de707ddcfcc8d97d13a6 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 23 Aug 2016 11:36:04 +0300 Subject: SCI32: Fix restoring games from Torin's game restore dialog The list in kListEachElementDo may be invalidated after a selector invocation --- engines/sci/engine/klists.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/engines/sci/engine/klists.cpp b/engines/sci/engine/klists.cpp index 53be26b37f..bc559148ac 100644 --- a/engines/sci/engine/klists.cpp +++ b/engines/sci/engine/klists.cpp @@ -576,6 +576,10 @@ reg_t kListEachElementDo(EngineState *s, int argc, reg_t *argv) { } } else { invokeSelector(s, curObject, slc, argc, argv, argc - 2, argv + 2); + // Check if the list has been invalidated after the call above + // (e.g. when restoring in Torin) + if (s->_segMan->getSegmentType(argv[0].getSegment()) != SEG_TYPE_LISTS) + return s->r_acc; } curNode = s->_segMan->lookupNode(list->nextNodes[list->numRecursions]); -- cgit v1.2.3