From 9336278b454720da4f6288ed475fd56d09b44a2b Mon Sep 17 00:00:00 2001 From: Simon Delamarre Date: Sat, 28 Feb 2026 11:08:01 +0100 Subject: [PATCH] IMAGE: Handle ANI files wrongly including header size in the chunk size field Found for example in Adi4's waiting cursor "WAIT.ANI" --- image/ani.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/image/ani.cpp b/image/ani.cpp index f662292205b..218a30b55e6 100644 --- a/image/ani.cpp +++ b/image/ani.cpp @@ -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(chunkAvailable); + actualChunkSize = chunkSize; + } else { + warning("AniDecoder::parseRIFFChunk: RIFF chunk is too large"); + return false; + } } RIFFChunkDef chunkDef;