Skip to content

Commit

Permalink
Fix an assert in contour_measure.cpp
Browse files Browse the repository at this point in the history
Since fp32 has finite precision, a segment may reasonably become degenerate with length 0, and we need to be robust enough to handle this. Asserting that the distance is non-negative is still a good test.

Fixes #7210.

Diffs=
806ae1fae Fix an assert in contour_measure.cpp (#7232)

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
  • Loading branch information
csmartdalton and csmartdalton committed May 8, 2024
1 parent 49a9ac5 commit 8e68ab7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7d03c3fafeefd05513c4a418f320322ecd1c1e4e
806ae1faea4cc10452c76a4ce2b35f2ca12aa469
2 changes: 1 addition & 1 deletion src/math/contour_measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ContourMeasure::ContourMeasure(std::vector<Segment>&& segs,
// or the last segment if distance == m_distance
size_t ContourMeasure::findSegment(float distance) const
{
assert(m_segments.front().m_distance > 0);
assert(m_segments.front().m_distance >= 0);
assert(m_segments.back().m_distance == m_length);

assert(distance >= 0 && distance <= m_length);
Expand Down

0 comments on commit 8e68ab7

Please sign in to comment.