IMAGE: Handle ANI files wrongly including header size in the chunk size field

Found for example in Adi4's waiting cursor "WAIT.ANI"
This commit is contained in:
Simon Delamarre
2026-02-28 11:08:01 +01:00
parent 15c477d631
commit 9336278b45
+9 -2
View File
@@ -125,8 +125,15 @@ bool AniDecoder::parseRIFFChunks(Common::SeekableReadStream &stream, const RIFFC
int64 chunkAvailable = stream.size() - stream.pos();
if (chunkAvailable < actualChunkSize) {
warning("AniDecoder::parseRIFFChunk: RIFF chunk is too large");
return false;
if (chunkAvailable == chunkSize - 8) {
// Some ANI files wrongly include the 8-byte chunk header size in the chunk size field, tolerate that
warning("AniDecoder::parseRIFFChunks: Chunk size seems to include header size, clamping");
chunkSize = static_cast<uint32>(chunkAvailable);
actualChunkSize = chunkSize;
} else {
warning("AniDecoder::parseRIFFChunk: RIFF chunk is too large");
return false;
}
}
RIFFChunkDef chunkDef;