Skip to content

Require numPoints >= 3 for NaturalCubicSpline and NaturalQuinticSpline#137

Open
CodeReclaimers wants to merge 1 commit intodavideberly:masterfrom
CodeReclaimers:fix/natural-spline-2point-segfault
Open

Require numPoints >= 3 for NaturalCubicSpline and NaturalQuinticSpline#137
CodeReclaimers wants to merge 1 commit intodavideberly:masterfrom
CodeReclaimers:fix/natural-spline-2point-segfault

Conversation

@CodeReclaimers
Copy link
Contributor

Summary

  • With 2 points, RowReduce accesses mDelta[1] out of bounds (heap-buffer-overflow). The multi-segment solver requires at least 2 segments (3 points). Changed assertion from numPoints >= 2 to numPoints >= 3 in both NaturalCubicSpline and NaturalQuinticSpline, and updated documentation comment.

Test plan

  • Confirmed segfault with 2-point free quintic spline before fix (AddressSanitizer confirms heap-buffer-overflow at NaturalQuinticSpline.h:336)
  • After fix, 2-point construction triggers clean assertion with descriptive message
  • 3-point splines construct and evaluate correctly

🤖 Generated with Claude Code

With 2 points, RowReduce accesses mDelta[1] which is out of bounds
(mDelta has only 1 element), causing a heap-buffer-overflow. The
multi-segment solver requires at least 2 segments (3 points) for
its row reduction to work correctly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments