0030533: Data Exchange - Crash during STEP import.
authorika <ika@opencascade.com>
Thu, 28 Feb 2019 14:56:47 +0000 (17:56 +0300)
committerapn <apn@opencascade.com>
Sun, 3 Mar 2019 17:58:37 +0000 (20:58 +0300)
Add Null checks to avoid crash during reading faces without bounds.

src/STEPCAFControl/STEPCAFControl_Reader.cxx
tests/bugs/step/bug30533 [new file with mode: 0644]

index 15a2488..8852b56 100644 (file)
@@ -4547,6 +4547,8 @@ void STEPCAFControl_Reader::ExpandShell(const Handle(StepShape_ConnectedFaceSet)
 
     // Access face bounds
     Handle(StepShape_HArray1OfFaceBound) aWires = aFace->Bounds();
+    if (aWires.IsNull())
+      continue;
     for (Standard_Integer w = aWires->Lower(); w <= aWires->Upper(); ++w)
     {
       const Handle(StepShape_Loop)& aWire = aWires->Value(w)->Bound();
@@ -4564,7 +4566,12 @@ void STEPCAFControl_Reader::ExpandShell(const Handle(StepShape_ConnectedFaceSet)
       Handle(StepShape_HArray1OfOrientedEdge) anEdges = anEdgeLoop->EdgeList();
       for (Standard_Integer e = anEdges->Lower(); e <= anEdges->Upper(); ++e)
       {
-        Handle(StepShape_Edge) anEdge = anEdges->Value(e)->EdgeElement();
+        Handle(StepShape_OrientedEdge) anOrientedEdge = anEdges->Value(e);
+        if (anOrientedEdge.IsNull())
+          continue;
+        Handle(StepShape_Edge) anEdge = anOrientedEdge->EdgeElement();
+        if (anEdge.IsNull())
+          continue;
 
         // Record CAF data
         SettleShapeData(anEdge, RootLab, ShapeTool, TP);
diff --git a/tests/bugs/step/bug30533 b/tests/bugs/step/bug30533
new file mode 100644 (file)
index 0000000..e2f0226
--- /dev/null
@@ -0,0 +1,25 @@
+puts "==================================================="
+puts " 0030533: Data Exchange - Crash during STEP import."
+puts "==================================================="
+puts ""
+
+pload DCAF
+
+param read.stepcaf.subshapes.name On
+
+ReadStep D [locate_data_file bug30533.stp]
+
+# Check imported names
+set name [GetName D 0:1:1:5:1]
+if {$name != "NONE"} {
+  puts "Error: wrong name of subshape"
+}
+set name [GetName D 0:1:1:5:2]
+if {$name != "NONE"} {
+  puts "Error: wrong name of subshape"
+}
+
+Close D
+
+# return param to default value
+param read.stepcaf.subshapes.name Off