Fix (unreported): off-by-one error when setting curve handles

The problem is that `current_mask` can become `selection.size()`.
The loop could also be refactored to break out of it when the end
of the selection is reached. This can be done separately.
This commit is contained in:
Jacques Lucke 2021-12-05 14:49:30 +01:00
parent 5ef5a9fc24
commit d19443074a
1 changed files with 2 additions and 2 deletions

View File

@ -75,7 +75,7 @@ static void set_position_in_component(const GeometryNodeCurveHandleMode mode,
if (spline->type() == Spline::Type::Bezier) {
BezierSpline &bezier = static_cast<BezierSpline &>(*spline);
for (int i : bezier.positions().index_range()) {
if (selection[current_mask] == current_point) {
if (current_mask < selection.size() && selection[current_mask] == current_point) {
if (mode & GEO_NODE_CURVE_HANDLE_LEFT) {
if (bezier.handle_types_left()[i] == BezierSpline::HandleType::Vector) {
bezier.ensure_auto_handles();
@ -103,7 +103,7 @@ static void set_position_in_component(const GeometryNodeCurveHandleMode mode,
}
else {
for (int UNUSED(i) : spline->positions().index_range()) {
if (selection[current_mask] == current_point) {
if (current_mask < selection.size() && selection[current_mask] == current_point) {
current_mask++;
}
current_point++;