0030562: Coding - TopOpeBRepBuild_Builder use of null pointer
authorkgv <kgv@opencascade.com>
Tue, 12 Mar 2019 17:22:26 +0000 (20:22 +0300)
committerapn <apn@opencascade.com>
Wed, 13 Mar 2019 13:39:41 +0000 (16:39 +0300)
TopOpeBRepBuild_Builder::Clear() - added NULL check.

src/TopOpeBRepBuild/TopOpeBRepBuild_Builder.cxx

index a282487..e39324e 100644 (file)
@@ -194,29 +194,43 @@ void TopOpeBRepBuild_Builder::AddIntersectionEdges
 //=======================================================================
 void TopOpeBRepBuild_Builder::Clear()
 {
+  if (myDataStructure.IsNull())
+  {
+    myMergedOUT.Clear();
+    myMergedIN.Clear();
+    myMergedON.Clear();
+    return;
+  }
+
   const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS();
-  TopOpeBRepDS_DataMapIteratorOfDataMapOfShapeListOfShapeOn1State it;
-  for (it.Initialize(mySplitOUT); it.More(); it.Next()) {
+  for (TopOpeBRepDS_DataMapIteratorOfDataMapOfShapeListOfShapeOn1State it (mySplitOUT); it.More(); it.Next())
+  {
     const TopoDS_Shape& e = it.Key();
-    if ( e.ShapeType() == TopAbs_EDGE ) {
+    if (e.ShapeType() == TopAbs_EDGE)
+    {
       Standard_Boolean isse =  BDS.IsSectionEdge(TopoDS::Edge(e));
       if (!isse) mySplitOUT.ChangeFind(e).Clear();
     }
   }
-  for (it.Initialize(mySplitIN); it.More(); it.Next()) {
+  for (TopOpeBRepDS_DataMapIteratorOfDataMapOfShapeListOfShapeOn1State it (mySplitIN); it.More(); it.Next())
+  {
     const TopoDS_Shape& e = it.Key();
-    if ( e.ShapeType() == TopAbs_EDGE ) {
+    if (e.ShapeType() == TopAbs_EDGE)
+    {
       Standard_Boolean isse =  BDS.IsSectionEdge(TopoDS::Edge(e));
       if (!isse) mySplitIN.ChangeFind(e).Clear();
     }
   }
-  for (it.Initialize(mySplitON); it.More(); it.Next()) {
+  for (TopOpeBRepDS_DataMapIteratorOfDataMapOfShapeListOfShapeOn1State it (mySplitON); it.More(); it.Next())
+  {
     const TopoDS_Shape& e = it.Key();
-    if ( e.ShapeType() == TopAbs_EDGE ) {
+    if (e.ShapeType() == TopAbs_EDGE)
+    {
       Standard_Boolean isse =  BDS.IsSectionEdge(TopoDS::Edge(e));
       if (!isse) mySplitON.ChangeFind(e).Clear();
     }
   }
+
   myMergedOUT.Clear();
   myMergedIN.Clear();
   myMergedON.Clear();