Prevent the indices from overflowing

This commit is contained in:
Jean Pierre Cimalando 2021-04-14 01:26:26 +02:00
parent e3b0260d9c
commit 9e15fa5e7c

View file

@ -641,8 +641,10 @@ namespace _internals {
template <class T>
void snippetSFZInterpolationCast(const T*& floatJump, int*& jump, T*& coeff)
{
*jump = static_cast<int>(*floatJump);
*coeff = *floatJump - static_cast<float>(*jump);
constexpr float maxJump { 1 << 24 };
const float limitedJump = min(maxJump, *floatJump);
*jump = static_cast<int>(limitedJump);
*coeff = limitedJump - static_cast<float>(*jump);
incrementAll(floatJump, coeff, jump);
}
}