Skip to content

Commit

Permalink
AudioFormatReaderSource: Avoid reading past the end of the wrapped Au…
Browse files Browse the repository at this point in the history
…dioFormatReader
  • Loading branch information
reuk committed Jan 25, 2023
1 parent 273275c commit c56102f
Showing 1 changed file with 8 additions and 2 deletions.
Expand Up @@ -81,8 +81,14 @@ void AudioFormatReaderSource::getNextAudioBlock (const AudioSourceChannelInfo& i
}
else
{
reader->read (info.buffer, info.startSample,
info.numSamples, start, true, true);
const auto samplesToRead = jlimit (int64{},
(int64) info.numSamples,
reader->lengthInSamples - start);

reader->read (info.buffer, info.startSample, (int) samplesToRead, start, true, true);
info.buffer->clear ((int) (info.startSample + samplesToRead),
(int) (info.numSamples - samplesToRead));

nextPlayPos += info.numSamples;
}
}
Expand Down

0 comments on commit c56102f

Please sign in to comment.