it seems to me that the initialisation of numSamples
is wrong in this constructor and could lead to out-of-bounds access:
AudioBlock (AudioBuffer<SampleType>& buffer, size_t startSampleIndex) noexcept
: channels (buffer.getArrayOfWritePointers()),
numChannels (static_cast<ChannelCountType> (buffer.getNumChannels())),
startSample (startSampleIndex),
numSamples (static_cast<size_t> (buffer.getNumSamples()))
{
jassert (startSample < numSamples);
}
shouldn’t it be like that?
numSamples (static_cast<size_t> (buffer.getNumSamples()) - startSampleIndex)
btw I would rather have numberOfSamples
as parameter. I don’t really see the use of this constructor as it is. but perhaps I’m missing something, I’m not really used to AudioBlock yet.