diff options
author | Paul Gilbert | 2010-06-26 00:36:43 +0000 |
---|---|---|
committer | Paul Gilbert | 2010-06-26 00:36:43 +0000 |
commit | ab261facee90ede5dd7dd5bf38262745eef3e946 (patch) | |
tree | ab972ee855a5967e5ba7df688635dc506713b753 | |
parent | 5ba7be88b8641e8cc8b4760b44d87ddc7b1ed0f7 (diff) | |
download | scummvm-rg350-ab261facee90ede5dd7dd5bf38262745eef3e946.tar.gz scummvm-rg350-ab261facee90ede5dd7dd5bf38262745eef3e946.tar.bz2 scummvm-rg350-ab261facee90ede5dd7dd5bf38262745eef3e946.zip |
Added extra validation for sprite decoding
svn-id: r50297
-rw-r--r-- | engines/m4/sprite.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/engines/m4/sprite.cpp b/engines/m4/sprite.cpp index 4ce1b75b35..641b93baea 100644 --- a/engines/m4/sprite.cpp +++ b/engines/m4/sprite.cpp @@ -121,6 +121,8 @@ void M4Sprite::loadDeltaRle(Common::SeekableReadStream* rleData, int destX, int // TODO: The sprite outlines (pixel value 0xFD) are not shown void M4Sprite::loadMadsSprite(Common::SeekableReadStream* source) { + bool spriteEnd = false; + // Set entire sprite contents to transparent pixels fillRect(bounds(), TRANSPARENT_COLOUR_INDEX); @@ -131,10 +133,14 @@ void M4Sprite::loadMadsSprite(Common::SeekableReadStream* source) { byte cmd = source->readByte(); int x2 = 0; - if (cmd == 0xff) + if (cmd == 0xfc) { + // End of entire sprite + spriteEnd = true; + break; + } else if (cmd == 0xff) { // The entire line is empty newLine = true; - else if (cmd == 0xFD) { + } else if (cmd == 0xFD) { // Lines contains only run lenghs of pixels while (x2 < w) { cmd = source->readByte(); @@ -189,6 +195,11 @@ void M4Sprite::loadMadsSprite(Common::SeekableReadStream* source) { } while (source->readByte() != 0xff); } } + + if (!spriteEnd) { + byte v = source->readByte(); + assert(v == 0xFC); + } } byte M4Sprite::getTransparencyIndex() const { |