Skip to content

Require numPoints >= 3 for NaturalCubicSpline and NaturalQuinticSpline#137

Merged
davideberly merged 2 commits intodavideberly:masterfrom
CodeReclaimers:fix/natural-spline-2point-segfault
Feb 28, 2026
Merged

Require numPoints >= 3 for NaturalCubicSpline and NaturalQuinticSpline#137
davideberly merged 2 commits 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

CodeReclaimers and others added 2 commits February 18, 2026 13:48
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>
@davideberly davideberly merged commit 389f187 into davideberly:master Feb 28, 2026
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.

2 participants