From f159fc09332c0e14b22f7d679b887e4af89876e8 Mon Sep 17 00:00:00 2001 From: Dmitrii Kulikov <164657232+AtheneNoctuaPt@users.noreply.github.com> Date: Thu, 5 Feb 2026 13:32:43 +0000 Subject: [PATCH] Modelling - Fixed crash in ComputePolesIndexes() (#1049) - Replaced partial bound checks with `std::clamp()` to validate both bounds for `theOutMinIdx` and `theOutMaxIdx` - Renamed local variable `mult` to `aMultiplier` for better clarity --- src/ModelingData/TKGeomBase/BndLib/BndLib_AddSurface.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ModelingData/TKGeomBase/BndLib/BndLib_AddSurface.cxx b/src/ModelingData/TKGeomBase/BndLib/BndLib_AddSurface.cxx index a2bbaafe44..b482fc119b 100644 --- a/src/ModelingData/TKGeomBase/BndLib/BndLib_AddSurface.cxx +++ b/src/ModelingData/TKGeomBase/BndLib/BndLib_AddSurface.cxx @@ -222,17 +222,17 @@ void ComputePolesIndexes(const NCollection_Array1& theKnots, int& theOutMaxIdx) { BSplCLib::Hunt(theKnots, theMin, theOutMinIdx); - theOutMinIdx = std::max(theOutMinIdx, theKnots.Lower()); + theOutMinIdx = std::clamp(theOutMinIdx, theKnots.Lower(), theKnots.Upper()); BSplCLib::Hunt(theKnots, theMax, theOutMaxIdx); theOutMaxIdx++; - theOutMaxIdx = std::min(theOutMaxIdx, theKnots.Upper()); - int mult = theMults(theOutMaxIdx); + theOutMaxIdx = std::clamp(theOutMaxIdx, theKnots.Lower(), theKnots.Upper()); + const int aMultiplier = theMults(theOutMaxIdx); theOutMinIdx = BSplCLib::PoleIndex(theDegree, theOutMinIdx, theIsPeriodic, theMults) + 1; theOutMinIdx = std::max(theOutMinIdx, 1); theOutMaxIdx = BSplCLib::PoleIndex(theDegree, theOutMaxIdx, theIsPeriodic, theMults) + 1; - theOutMaxIdx += theDegree - mult; + theOutMaxIdx += theDegree - aMultiplier; if (!theIsPeriodic) theOutMaxIdx = std::min(theOutMaxIdx, theMaxPoleIdx); }