From 62f2763bf794dfb711fd48e32d7c2162bdb5aed8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2016 14:59:11 -0400 Subject: [PATCH] VIDEO: Respect RIFF filesize field when decoding AVI files Starship Titanic in particular needs this, since some of the videos have extra junk at the end of the file, such as ycursors.avi, and parsing fails if we don't respect the filesize field --- video/avi_decoder.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/video/avi_decoder.cpp b/video/avi_decoder.cpp index 52a55f600c4..8f1bec4388b 100644 --- a/video/avi_decoder.cpp +++ b/video/avi_decoder.cpp @@ -296,7 +296,7 @@ bool AVIDecoder::loadStream(Common::SeekableReadStream *stream) { return false; } - /* uint32 fileSize = */ stream->readUint32LE(); + uint32 fileSize = stream->readUint32LE(); uint32 riffType = stream->readUint32BE(); if (riffType != ID_AVI) { @@ -307,7 +307,7 @@ bool AVIDecoder::loadStream(Common::SeekableReadStream *stream) { _fileStream = stream; // Go through all chunks in the file - while (parseNextChunk()) + while (_fileStream->pos() < fileSize && parseNextChunk()) ; if (!_decodedHeader) {