Skip to content

Commit

Permalink
Fix bad indexing error with open splines
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasp85 committed Mar 12, 2019
1 parent 4fa7b1a commit 1760568
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ggforce (development version)

- Fixed a bug in the calculation of open and closed b-splines, where the
interval would exceed the defined region and result in an out-of-bounds memory
error

# ggforce 0.2.0

## New features
Expand Down
7 changes: 6 additions & 1 deletion src/bSpline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ NumericMatrix splinePath(NumericVector x, NumericVector y, int degree, std::vect
controls.push_back(controls[2]);
}
NumericMatrix res(detail, 2);
double zJump = (knots[knots.size()-1-degree] - knots[degree]) / double(detail-1);
double zJump = (knots[knots.size()-1-degree] - knots[degree]);
if (type == "clamped") {
zJump /= double(detail-1);
} else {
zJump /= double(detail);
}
double z;
Point point;
for (int i = 0; i < detail; i++) {
Expand Down

0 comments on commit 1760568

Please sign in to comment.