Skip to content

Commit

Permalink
Sketch: Fix possible crash in BSpline::splineValue
Browse files Browse the repository at this point in the history
There is an underflow of an unsigned int in the calling instance that sets the parameter 'p' to 2**32-1.
But the size of the passed vector is 0. To fix the crash first check if p is less then the size of the vector.

See: https://forum.freecad.org/viewtopic.php?t=92815
  • Loading branch information
wwmayer committed Dec 9, 2024
1 parent 46f561e commit b30430c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Mod/Sketcher/App/planegcs/Geo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ double BSpline::splineValue(double x, size_t k, unsigned int p, VEC_D& d, const
}
}

return d[p];
return p < d.size() ? d[p] : 0.0;
}

void BSpline::setupFlattenedKnots()
Expand Down

0 comments on commit b30430c

Please sign in to comment.