From e208659aa877a034920cf9131a27db2aeb6c5d03 Mon Sep 17 00:00:00 2001 From: Coen Rampen Date: Sat, 18 Jun 2022 13:30:03 +0200 Subject: [PATCH] AUDIO: Fix VOC infinite loop This fixes a possible infinite loop in VocStream. It depends on the stream size matching the size specified in the VOC block headers, but if the size in the headers is incorrect and larger than the stream size, it will keep trying to read the stream. This is fixed by adding an end-of-stream check to the error check. --- audio/decoders/voc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/decoders/voc.cpp b/audio/decoders/voc.cpp index 30bb2ed0412..0fb80634080 100644 --- a/audio/decoders/voc.cpp +++ b/audio/decoders/voc.cpp @@ -168,9 +168,9 @@ int VocStream::fillBuffer(int maxSamples) { maxSamples -= samplesRead; _blockLeft -= samplesRead; - // In case of an error we will stop + // In case of an error or end of stream we will stop // stream playback. - if (_stream->err()) { + if (_stream->err() || _stream->eos()) { _blockLeft = 0; _curBlock = _blocks.end(); break;