From 1a6ffd6398339a82e79817c065bb0ae926dd4b63 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 5 May 2020 14:04:36 +0200 Subject: [PATCH] SCUMM: Fixed reading malformed resources. Bug #11463 --- engines/scumm/resource.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/engines/scumm/resource.cpp b/engines/scumm/resource.cpp index 597a291c957..6dccf993340 100644 --- a/engines/scumm/resource.cpp +++ b/engines/scumm/resource.cpp @@ -653,8 +653,14 @@ int ScummEngine::loadResource(ResType type, ResId idx) { if ((_game.version == 3) && !(_game.platform == Common::kPlatformAmiga) && (type == rtSound)) { return readSoundResourceSmallHeader(idx); } else { - size = _fileHandle->readUint16LE(); - _fileHandle->seek(-2, SEEK_CUR); + // WORKAROUND: Apple //gs MM has malformed sound resource #68 + if (_fileHandle->pos() + 2 > _fileHandle->size()) { + warning("loadResource(%s,%d): resource is too short", nameOfResType(type), idx); + size = 0; + } else { + size = _fileHandle->readUint16LE(); + _fileHandle->seek(-2, SEEK_CUR); + } } } else if (_game.features & GF_SMALL_HEADER) { if (_game.version == 4)