diff options
-rw-r--r-- | engines/sci/engine/gc.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/engines/sci/engine/gc.cpp b/engines/sci/engine/gc.cpp index e395eeab94..68b8054479 100644 --- a/engines/sci/engine/gc.cpp +++ b/engines/sci/engine/gc.cpp @@ -90,7 +90,8 @@ static void processWorkList(SegManager *segMan, WorklistManager &wm, const Commo wm._worklist.pop_back(); if (reg.segment != stackSegment) { // No need to repeat this one debugC(kDebugLevelGC, "[GC] Checking %04x:%04x", PRINT_REG(reg)); - if (reg.segment < heap.size() && heap[reg.segment]) { + // We only check for valid offsets here. Fixes bugs #3299458 and #3295849. + if (reg.segment < heap.size() && heap[reg.segment] && heap[reg.segment]->isValidOffset(reg.offset)) { // Valid heap object? Find its outgoing references! wm.pushArray(heap[reg.segment]->listAllOutgoingReferences(reg)); } |