Merge pull request #825 from jpcima/indices

Prevent the indices from overflowing
This commit is contained in:
JP Cimalando 2021-04-14 01:41:06 +02:00 committed by GitHub
commit ae5e27b7cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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);
}
}