Skip to content

Commit dc87495

Browse files
committed
GLUI: MorphCurveWidget: avoid reading past end for last curve segment
Signed-off-by: Stefan Westerfeld <stefan@space.twc.de>
1 parent 7262636 commit dc87495

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

glui/smmorphcurvewidget.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,12 @@ MorphCurveWidget::find_closest_segment_index (const Point& p)
484484
{
485485
Point curve_p = curve_point_to_xy (m_curve.points[i]);
486486
if (curve_p.x() < p.x())
487-
index = i;
487+
{
488+
if (i + 1 < m_curve.points.size())
489+
index = i;
490+
else
491+
index = -1; // no valid segment: p is not between two curve points
492+
}
488493
}
489494
return index;
490495
}

0 commit comments

Comments
 (0)