From 4241d3fae4642ccf6daa96797460bee74d4ac1b3 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 16 Aug 2021 20:19:58 +0300 Subject: [PATCH] SCI: Fix bug #12808 - restore the behavior of seek() in SCI With the latest changes to savegame streams, seeking to a location past the end of a file results in an assert. Restore the previous behavior, where the file pointer seeks to the maximum available file location. --- engines/sci/engine/kfile.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp index a214b16ff9b..84c8c228f0b 100644 --- a/engines/sci/engine/kfile.cpp +++ b/engines/sci/engine/kfile.cpp @@ -773,6 +773,7 @@ reg_t kFileIOSeek(EngineState *s, int argc, reg_t *argv) { FileHandle *f = getFileFromHandle(s, handle); if (f && f->_in) { + offset = MIN(offset, f->_in->size()); const bool success = f->_in->seek(offset, whence); if (getSciVersion() >= SCI_VERSION_2) { if (success) {