]> OCCT Git - occt.git/commitdiff
Modeling - Fix out-of-range access in BSplCLib_Reverse function (#863)
authorPasukhin Dmitry <dpasukhi@opencascade.com>
Sat, 29 Nov 2025 21:54:09 +0000 (21:54 +0000)
committerGitHub <noreply@github.com>
Sat, 29 Nov 2025 21:54:09 +0000 (21:54 +0000)
- Added a conditional check `if (aL < aUpper)` to prevent accessing array elements beyond bounds when `aL` equals or exceeds `aUpper`

src/FoundationClasses/TKMath/BSplCLib/BSplCLib_CurveComputation.pxx

index 0534d0afc9a27ac8c5a46540d9ec7d65161654a7..bb9b6bf0ff41477ca4ff3422cdec9747cf6d28e3 100644 (file)
@@ -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