]> OCCT Git - occt.git/commitdiff
0025559: SIGSEGV in TKMath when computing max tolerance of curve on surface
authoraml <aml@opencascade.com>
Thu, 11 Dec 2014 13:17:04 +0000 (16:17 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 11 Dec 2014 13:18:07 +0000 (16:18 +0300)
Fixed possible being outside the boundaries. Changed check math_Recipes to work with NaN, Inf, Ind.

Test case for issue CR25559

src/BOPTools/BOPTools_AlgoTools_1.cxx
src/math/math_Recipes.cxx
tests/bugs/modalg_5/bug25559 [new file with mode: 0755]

index 439b185672fc483db1e0f1a1142420eaff814556..46368c048e6d158ce16a5e5fb0c453a0c75a246e 100644 (file)
@@ -344,6 +344,8 @@ class BOPTools_CheckCurveOnSurface :
                                  Standard_Real& theFVal) {
     try {
       const Standard_Real aPar = theX(1);
+      if (!CheckParameter(aPar))
+        return Standard_False;
       gp_Pnt aP1, aP2;
       gp_Pnt2d aP2d;
       my3DCurve->D0(aPar, aP1);
@@ -367,7 +369,8 @@ class BOPTools_CheckCurveOnSurface :
                                     math_Vector& theGrad) {
     try {
       const Standard_Real aPar = theX(1);
-      
+      if (!CheckParameter(aPar))
+        return Standard_False;
       gp_Pnt aP1, aP2;
       gp_Vec aDC3D, aDSU, aDSV;
       gp_Pnt2d aP2d;
@@ -417,6 +420,19 @@ class BOPTools_CheckCurveOnSurface :
   }
   //
  private:
+
+  Standard_Boolean CheckParameter(const Standard_Real theParam)
+  {
+    if (theParam < my3DCurve->FirstParameter() ||
+        theParam > my3DCurve->LastParameter()  ||
+        theParam < my2DCurve->FirstParameter() ||
+        theParam > my2DCurve->LastParameter() )
+    {
+      return Standard_False;
+    }
+    return Standard_True;
+  }
+
   Handle(Geom_Curve) my3DCurve;
   Handle(Geom2d_Curve) my2DCurve;
   Handle(Geom_Surface) mySurf;
index 975171ab284d04b55cf38bfd7d7cd0d77117847e..97794a1e1eff8261ef33f3b616e602865fefba58 100644 (file)
@@ -205,10 +205,13 @@ Standard_Integer LU_Decompose(math_Matrix& a,
          for(k = 1; k < j; k++) 
            sum -= a(i,k) * a(k,j);
          a(i,j) = sum;
-         if((dum = vv(i) * fabs(sum)) >= big) {
-           big = dum;
-           imax = i;
+         // Note that comparison is made so as to have imax updated even if argument is NAN, Inf or IND, see #25559
+         if((dum = vv(i) * fabs(sum)) < big)
+         {
+           continue;
          }
+         big = dum;
+         imax = i;
        }
        if(j != imax) {
          for(k = 1; k <= n; k++) {
diff --git a/tests/bugs/modalg_5/bug25559 b/tests/bugs/modalg_5/bug25559
new file mode 100755 (executable)
index 0000000..5ad4e18
--- /dev/null
@@ -0,0 +1,11 @@
+puts "============"
+puts "OCC25559"
+puts "============"
+puts ""
+######################################################
+# SIGSEGV in TKMath when computing max tolerance of curve on surface
+######################################################
+
+restore [locate_data_file bug25559_f.brep] f
+
+checkcurveonsurf f