Skip to content

Commit

Permalink
make AudioFormatInputSource bound-safe
Browse files Browse the repository at this point in the history
  • Loading branch information
CrSjimo committed Oct 14, 2024
1 parent 76cc2a0 commit 4307b8a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/format/source/AudioFormatInputSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,14 @@ namespace talcs {
Q_D(AudioFormatInputSource);
QMutexLocker locker(&d->mutex);
Q_ASSERT(d->io && isOpen());
auto readLength = qMin(readData.length, length() - d->position);
auto readLength = qBound(qint64(0), readData.length, length() - d->position);
d->resampler->process(readData);
if (d->doStereoize && d->io->channelCount() == 1 && readData.buffer->channelCount() > 1) {
readData.buffer->setSampleRange(1, readData.startPos, readLength, *readData.buffer, 0, readData.startPos);
}
for (int ch = 0; ch < readData.buffer->channelCount(); ch++) {
readData.buffer->clear(ch, readData.startPos + readLength, readData.length - readLength);
}
d->position += readLength;
return readLength;
}
Expand Down

0 comments on commit 4307b8a

Please sign in to comment.