0025175: avoid unsafe 3D curve usages
[occt.git] / src / BRepBuilderAPI / BRepBuilderAPI_Sewing.cxx
index fb26f0b..e2787e0 100644 (file)
@@ -1057,6 +1057,7 @@ void BRepBuilderAPI_Sewing::EvaluateDistances(TopTools_SequenceOfShape& sequence
     TopLoc_Location loc;
     Standard_Real first, last;
     Handle(Geom_Curve) c3d = BRep_Tool::Curve(sec, loc, first, last);
+    if (c3d.IsNull()) continue;
     if (!loc.IsIdentity()) {
       c3d = Handle(Geom_Curve)::DownCast(c3d->Copy());
       c3d->Transform(loc.Transformation());
@@ -3604,15 +3605,16 @@ void BRepBuilderAPI_Sewing::Cutting(const Handle(Message_ProgressIndicator)& the
     const TopoDS_Edge& bound = TopoDS::Edge(myBoundFaces.FindKey(i));
     // Do not cut floating edges
     if (!myBoundFaces(i).Extent()) continue;
+    // Obtain bound curve
+    c3d = BRep_Tool::Curve(bound, loc, first, last);
+    if (c3d.IsNull()) continue;
+    if (!loc.IsIdentity()) {
+      c3d = Handle(Geom_Curve)::DownCast(c3d->Copy());
+      c3d->Transform(loc.Transformation());
+    }
     // Create cutting sections
     TopTools_ListOfShape listSections;
     { //szv: Use brackets to destroy local variables
-      // Obtain bound curve
-      c3d = BRep_Tool::Curve(bound, loc, first, last);
-      if (!loc.IsIdentity()) {
-        c3d = Handle(Geom_Curve)::DownCast(c3d->Copy());
-        c3d->Transform(loc.Transformation());
-      }
       // Obtain candidate vertices
       TopoDS_Vertex V1, V2;
       TopTools_IndexedMapOfShape CandidateVertices;