]> OCCT Git - occt-copy.git/commitdiff
0030708: Modeling Data - Exception is raised while initializing TopoDS_Iterator with...
authoremv <emv@opencascade.com>
Mon, 13 May 2019 09:32:09 +0000 (12:32 +0300)
committeremv <emv@opencascade.com>
Wed, 15 May 2019 11:04:11 +0000 (14:04 +0300)
Added protection from null shapes to TopoDS_Iterator::Initialize method.

src/QABugs/QABugs_19.cxx
src/TopoDS/TopoDS_Iterator.cxx
tests/bugs/moddata_3/bug30708_1 [new file with mode: 0644]
tests/bugs/moddata_3/bug30708_2 [new file with mode: 0644]

index 497d270779a25b9a5f708cbd29a35376696335d4..39ab345eedb2015f9e0cf8a19043e1b99dff7d5b 100755 (executable)
@@ -4310,6 +4310,54 @@ static Standard_Integer OCC26313(Draw_Interpretor& di,Standard_Integer n,const c
   return 0;
 }
 
+//=======================================================================
+//function : OCC30708_1 
+//purpose  : Tests initialization of the TopoDS_Iterator with null shape
+//=======================================================================
+static Standard_Integer OCC30708_1 (Draw_Interpretor& di, Standard_Integer, const char**)
+{
+  TopoDS_Iterator it;
+  try
+  {
+    OCC_CATCH_SIGNALS
+
+    TopoDS_Shape empty;
+    it.Initialize (empty);
+
+  }
+  catch (Standard_Failure)
+  {
+    di << "Cannot initialize TopoDS_Iterator with null shape\n";
+    return 0;
+  }
+
+  if (it.More())
+    di << "Incorrect Iterator initialization: method More() returns true on null shape\n";
+
+  return 0;
+}
+
+//=======================================================================
+//function : OCC30708_2
+//purpose  : Tests initialization of the BRepLib_MakeWire with null wire
+//=======================================================================
+static Standard_Integer OCC30708_2 (Draw_Interpretor& di, Standard_Integer, const char**)
+{
+  try
+  {
+    OCC_CATCH_SIGNALS
+
+    TopoDS_Wire empty;
+    BRepLib_MakeWire aWBuilder (empty);
+  }
+  catch (Standard_Failure)
+  {
+    di << "Cannot initialize BRepLib_MakeWire with null wire\n";
+  }
+
+  return 0;
+}
+
 void QABugs::Commands_19(Draw_Interpretor& theCommands) {
   const char *group = "QABugs";
 
@@ -4401,5 +4449,11 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) {
 
   theCommands.Add ("OCC26313", "OCC26313 result shape", __FILE__, OCC26313, group);
 
+  theCommands.Add ("OCC30708_1", "Tests initialization of the TopoDS_Iterator with null shape",
+                   __FILE__, OCC30708_1, group);
+
+  theCommands.Add ("OCC30708_2", "Tests initialization of the BRepLib_MakeWire with null shape",
+                   __FILE__, OCC30708_2, group);
+
   return;
 }
index a4534fbebdd422a1a44efed4a60815d2709d490b..53220fbb27a263cb9eabf3db41bd34686acb8755 100644 (file)
@@ -23,7 +23,6 @@
 //function : Initialize
 //purpose  : 
 //=======================================================================
-
 void TopoDS_Iterator::Initialize(const TopoDS_Shape& S,
                                  const Standard_Boolean cumOri,
                                  const Standard_Boolean cumLoc)
@@ -36,13 +35,16 @@ void TopoDS_Iterator::Initialize(const TopoDS_Shape& S,
     myOrientation = S.Orientation();
   else
     myOrientation = TopAbs_FORWARD;
-  myShapes.Initialize(S.TShape()->Shapes());
+
+  if (S.IsNull())
+    myShapes = TopoDS_ListIteratorOfListOfShape();
+  else
+    myShapes.Initialize(S.TShape()->myShapes);
+
   if (More()) {
     myShape = myShapes.Value();
     myShape.Orientation(TopAbs::Compose(myOrientation,myShape.Orientation()));
-    //modified by NIZNHY-PKV Fri Jan 16 07:42:30 2009f
     if (!myLocation.IsIdentity())
-    //modified by NIZNHY-PKV Fri Jan 16 07:42:37 2009t
       myShape.Move(myLocation);
   }
 }
@@ -58,9 +60,7 @@ void TopoDS_Iterator::Next()
   if (More()) {
     myShape = myShapes.Value();
     myShape.Orientation(TopAbs::Compose(myOrientation,myShape.Orientation()));
-    //modified by NIZNHY-PKV Fri Jan 16 07:42:30 2009f
     if (!myLocation.IsIdentity())
-    //modified by NIZNHY-PKV Fri Jan 16 07:42:37 2009t
       myShape.Move(myLocation);
   }
 }
diff --git a/tests/bugs/moddata_3/bug30708_1 b/tests/bugs/moddata_3/bug30708_1
new file mode 100644 (file)
index 0000000..4d13220
--- /dev/null
@@ -0,0 +1,8 @@
+puts "================"
+puts "0030708: Modeling Data - Crash while initializing TopoDS_Iterator with null shape"
+puts "================"
+puts ""
+
+if { [regexp "Cannot initialize" [OCC30708_1]]} {
+  puts "Error: Cannot initialize TopoDS_Iterator with null shape"
+}
diff --git a/tests/bugs/moddata_3/bug30708_2 b/tests/bugs/moddata_3/bug30708_2
new file mode 100644 (file)
index 0000000..e3a8e5a
--- /dev/null
@@ -0,0 +1,8 @@
+puts "================"
+puts "0030708: Modeling Data - Crash while initializing TopoDS_Iterator with null shape"
+puts "================"
+puts ""
+
+if { [regexp "Cannot initialize" [OCC30708_2]]} {
+  puts "Error: Cannot initialize BRepLib_MakeWire with null wire"
+}