0030202: IntPatch_WLineTool::JoinWLines array out of bounds
authornbv <nbv@opencascade.com>
Fri, 5 Oct 2018 07:50:51 +0000 (10:50 +0300)
committerapn <apn@opencascade.com>
Wed, 10 Oct 2018 15:47:17 +0000 (18:47 +0300)
The main idea of the fix is that the creation of WLine with one point is forbidden.

src/IntPatch/IntPatch_ImpImpIntersection_4.gxx
tests/bugs/modalg_7/bug30202_1 [new file with mode: 0644]
tests/bugs/modalg_7/bug30202_2 [new file with mode: 0644]

index c1477b1..6ccc8b5 100644 (file)
@@ -3363,7 +3363,13 @@ static IntPatch_ImpImpIntersection::IntStatus
           aP.SetTolerance(aTol3D);
           aP.SetValue(aWLine[i]->Point(1).Value());
 
-          theSPnt.Append(aP);
+          //Check whether the added point exists.
+          //It is enough to check the last point.
+          if (theSPnt.IsEmpty() ||
+              !theSPnt.Last().PntOn2S().IsSame(aP.PntOn2S(), Precision::Confusion()))
+          {
+            theSPnt.Append(aP);
+          }
         }
         else if (aWLine[i]->NbPnts() > 1)
         {
@@ -3582,7 +3588,7 @@ static IntPatch_ImpImpIntersection::IntStatus
     // another point in the interval [anUC, anUsup] if anUC is intersection point and
     // in the interval [anUmid, anUC], otherwise.
 
-    Standard_Real anAddedPar[2] = { anUmid, anUmid };
+    Standard_Real anAddedPar[2] = {isReversed ? u2 : u1, isReversed ? u2 : u1};
 
     for (Standard_Integer aParID = 0; aParID < 2; aParID++)
     {
diff --git a/tests/bugs/modalg_7/bug30202_1 b/tests/bugs/modalg_7/bug30202_1
new file mode 100644 (file)
index 0000000..150f472
--- /dev/null
@@ -0,0 +1,64 @@
+puts "========"
+puts "0030202: IntPatch_WLineTool::JoinWLines array out of bounds"
+puts "========"
+puts ""
+
+restore [locate_data_file bug30202_src.brep] b1
+restore [locate_data_file bug30202_tool.brep] b2
+
+bclearobjects
+bcleartools
+baddobjects b1
+baddtools b2
+
+bfillds
+
+bbop r_0 0
+bbop r_1 1
+bbop r_2 2
+bbop r_3 3
+bbop r_4 4
+
+
+checkshape r_0
+checknbshapes r_0 -solid 1 -shell 1 -face 10 -wire 10
+checkprops r_0 -s 3.07923 -v 0.15225
+if {[regexp "Faulties" [bopargcheck r_0]]} {
+  puts "Error: bopargcheck has found some faulties in r_0"
+}
+
+checkshape r_1
+checknbshapes r_1 -solid 1 -shell 1 -face 31 -wire 33
+checkprops r_1 -s 128.978 -v 46.7138
+if {[regexp "Faulties" [bopargcheck r_1]]} {
+  puts "Error: bopargcheck has found some faulties in r_1"
+}
+
+checkshape r_2
+checknbshapes r_2 -solid 1 -shell 1 -face 29 -wire 31
+checkprops r_2 -s 117.75 -v 45.3505
+if {[regexp "Faulties" [bopargcheck r_2]]} {
+  puts "Error: bopargcheck has found some faulties in r_2"
+}
+
+checkshape r_3
+checknbshapes r_3 -solid 1 -shell 1 -face 12 -wire 12
+checkprops r_3 -s 14.3071 -v 1.2111
+if {[regexp "Faulties" [bopargcheck r_3]]} {
+  puts "Error: bopargcheck has found some faulties in r_3"
+}
+
+checkshape r_4
+checknbshapes r_4 -vertex 8 -edge 8
+checkprops r_4 -l 8.28981
+if {[regexp "Faulties" [bopargcheck r_4]]} {
+  puts "Error: bopargcheck has found some faulties in r_4"
+}
+
+checksection r_4 -r 0
+
+# FUSE
+copy r_1 result
+checkmaxtol result -min_tol 1.0e-4
+checkview -display result -2d -path ${imagedir}/${test_image}.png
+
diff --git a/tests/bugs/modalg_7/bug30202_2 b/tests/bugs/modalg_7/bug30202_2
new file mode 100644 (file)
index 0000000..533de34
--- /dev/null
@@ -0,0 +1,14 @@
+puts "========"
+puts "0030202: IntPatch_WLineTool::JoinWLines array out of bounds"
+puts "========"
+puts ""
+
+restore [locate_data_file bug30202_src.brep] b1
+restore [locate_data_file bug30202_tool.brep] b2
+
+explode b1 f
+explode b2 f
+
+if {![regexp "no 3d curves\n has no 3d points" [bopcurves b1_5 b2_7 -2d]]} {
+  puts "Error: Expected intersection result is empty"
+}