[Scummvm-git-logs] scummvm master -> 2bf31d318378c683d57dea5484fea6dc13db03cf

rvanlaar noreply at scummvm.org
Thu Aug 29 11:10:44 UTC 2024


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
2bf31d3183 DIRECTOR: Work around hitting EOS in bitmapCast


Commit: 2bf31d318378c683d57dea5484fea6dc13db03cf
    https://github.com/scummvm/scummvm/commit/2bf31d318378c683d57dea5484fea6dc13db03cf
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2024-08-29T13:10:32+02:00

Commit Message:
DIRECTOR: Work around hitting EOS in bitmapCast

In Majestic (D4-win)bitmap casts either have a size of 24 or 28.
Generic cast loading reads the first 2 bytes for type and flags1.

For D4 and D5 the BitmapCastMember loading code now checks if there's
more to read after the 22nd and 28th byte.

Note: For D5 the check is after the 30th byte, because of the
extra 2 bytes for the CastLibNum.

Changed paths:
    engines/director/castmember/bitmap.cpp


diff --git a/engines/director/castmember/bitmap.cpp b/engines/director/castmember/bitmap.cpp
index bbd24a125b3..dbd40d71f3c 100644
--- a/engines/director/castmember/bitmap.cpp
+++ b/engines/director/castmember/bitmap.cpp
@@ -99,12 +99,12 @@ BitmapCastMember::BitmapCastMember(Cast *cast, uint16 castId, Common::SeekableRe
 		_regY = stream.readUint16();
 		_regX = stream.readUint16();
 
-		stream.readByte();
-		_bitsPerPixel = stream.readByte();
+		_bitsPerPixel = 0;
 
-		if (stream.eos()) {
-			_bitsPerPixel = 0;
-		} else {
+		if (stream.pos() < stream.size()) {
+			// castSize is > 22 bytes
+			stream.readByte();
+			_bitsPerPixel = stream.readByte();
 			int clutCastLib = -1;
 			if (version >= kFileVer500) {
 				clutCastLib = stream.readSint16();
@@ -119,14 +119,17 @@ BitmapCastMember::BitmapCastMember(Cast *cast, uint16 castId, Common::SeekableRe
 				}
 				_clut = CastMemberID(clutId, clutCastLib);
 			}
-			stream.readUint16();
-			/* uint16 unk1 = */ stream.readUint16();
-			stream.readUint16();
+			if (stream.pos() < stream.size()) {
+				// castSize > 28 bytes on D4, > 30 bytes on D5
+				stream.readUint16();
+				/* uint16 unk1 = */ stream.readUint16();
+				stream.readUint16();
 
-			stream.readUint32();
-			stream.readUint32();
+				stream.readUint32();
+				stream.readUint32();
 
-			_flags2 = stream.readUint16();
+				_flags2 = stream.readUint16();
+			}
 		}
 
 		if (_bitsPerPixel == 0)




More information about the Scummvm-git-logs mailing list