From: Pasukhin Dmitry Date: Sat, 29 Nov 2025 21:54:09 +0000 (+0000) Subject: Modeling - Fix out-of-range access in BSplCLib_Reverse function (#863) X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=a91a0d189ae572df2cbeff770dcdd9d995bdc7e4;p=occt.git Modeling - Fix out-of-range access in BSplCLib_Reverse function (#863) - Added a conditional check `if (aL < aUpper)` to prevent accessing array elements beyond bounds when `aL` equals or exceeds `aUpper` --- diff --git a/src/FoundationClasses/TKMath/BSplCLib/BSplCLib_CurveComputation.pxx b/src/FoundationClasses/TKMath/BSplCLib/BSplCLib_CurveComputation.pxx index 0534d0afc9..bb9b6bf0ff 100644 --- a/src/FoundationClasses/TKMath/BSplCLib/BSplCLib_CurveComputation.pxx +++ b/src/FoundationClasses/TKMath/BSplCLib/BSplCLib_CurveComputation.pxx @@ -273,7 +273,10 @@ void BSplCLib_Reverse(Array& theArray, const Standard_Integer theL) const int aL = aLower + (theL - aLower) % theArray.Length(); std::reverse(&theArray(aLower), &theArray(aL) + 1); - std::reverse(&theArray(aL + 1), &theArray(aUpper) + 1); + if (aL < aUpper) + { + std::reverse(&theArray(aL + 1), &theArray(aUpper) + 1); + } } // Removes a knot from the B-spline curve