Check that the index passed to the curves arenot too crazy
This commit is contained in:
parent
61d1c568a8
commit
fbb9ebabb2
3 changed files with 18 additions and 0 deletions
|
|
@ -56,6 +56,7 @@ namespace config {
|
|||
constexpr size_t powerHistoryLength { 16 };
|
||||
constexpr float voiceStealingThreshold { 0.00001f };
|
||||
constexpr uint16_t numCCs { 512 };
|
||||
constexpr int maxCurves { 256 };
|
||||
constexpr int chunkSize { 1024 };
|
||||
constexpr int filtersInPool { maxVoices * 2 };
|
||||
constexpr int filtersPerVoice { 2 };
|
||||
|
|
|
|||
|
|
@ -196,6 +196,12 @@ void CurveSet::addCurve(const Curve& curve, int explicitIndex)
|
|||
{
|
||||
std::unique_ptr<Curve>* slot;
|
||||
|
||||
if (explicitIndex < -1)
|
||||
return;
|
||||
|
||||
if (explicitIndex >= config::maxCurves)
|
||||
return;
|
||||
|
||||
if (explicitIndex == -1) {
|
||||
if (_useExplicitIndexing)
|
||||
return; // reject implicit indices if any were explicit before
|
||||
|
|
|
|||
|
|
@ -199,6 +199,17 @@ TEST_CASE("[Curve] Add curves to CurveSet")
|
|||
REQUIRE( curveSet.getCurve(4).evalCC7(0) == 1.0f );
|
||||
}
|
||||
|
||||
TEST_CASE("[Curve] Add bad indices")
|
||||
{
|
||||
sfz::CurveSet curveSet;
|
||||
curveSet.addCurve(sfz::Curve::buildPredefinedCurve(0), -2);
|
||||
REQUIRE( curveSet.getNumCurves() == 0 );
|
||||
curveSet.addCurve(sfz::Curve::buildPredefinedCurve(0), 256);
|
||||
REQUIRE( curveSet.getNumCurves() == 0 );
|
||||
curveSet.addCurve(sfz::Curve::buildPredefinedCurve(0), 512);
|
||||
REQUIRE( curveSet.getNumCurves() == 0 );
|
||||
}
|
||||
|
||||
TEST_CASE("[Curve] Default CurveSet")
|
||||
{
|
||||
auto curveSet = sfz::CurveSet::createPredefined();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue