Fixed a segfault which would occur when the size of possibleRuleChanges was less than 3 (maxReplacementCount)

This commit is contained in:
Brian Small 2017-11-22 01:46:09 -08:00
parent 22d8dbee64
commit 6da2ca1b2f
1 changed files with 5 additions and 1 deletions

View File

@ -141,7 +141,11 @@ ContinuousTimeline<ShapeRule> fixStaticSegmentRules(const ContinuousTimeline<Sha
// Find best solution. Start with a single replacement, then increase as necessary.
RuleChangeScenario bestScenario(shapeRules, {}, animate);
for (int replacementCount = 1; bestScenario.getStaticSegmentCount() > 0 && replacementCount <= maxReplacementCount; ++replacementCount) {
for (
int replacementCount = 1;
bestScenario.getStaticSegmentCount() > 0 && replacementCount <= std::min(static_cast<int>(possibleRuleChanges.size()), maxReplacementCount);
++replacementCount
) {
// Only the first <replacementCount> elements of `currentRuleChanges` count
auto currentRuleChanges(possibleRuleChanges);
do {