0027404: Data Exchange - access violation when reading STEP file
authorgka <gka@opencascade.com>
Thu, 27 Oct 2016 14:50:18 +0000 (17:50 +0300)
committerapn <apn@opencascade.com>
Thu, 27 Oct 2016 14:50:59 +0000 (17:50 +0300)
Added check on the null handle
Test case for issue CR27404

src/STEPControl/STEPControl_Reader.cxx
tests/bugs/step/bug27404 [new file with mode: 0755]

index 3ef05c4..4997b11 100644 (file)
@@ -271,14 +271,17 @@ Standard_Integer STEPControl_Reader::NbRootsForTransfer()
                 Handle(StepShape_ShapeRepresentation)::DownCast(RR->Rep1());
               if(SR==SR2)
                 SR2 = Handle(StepShape_ShapeRepresentation)::DownCast(RR->Rep2());
-              Interface_EntityIterator subs2 = graph.Sharings(SR2);
-              for(subs2.Start(); subs2.More(); subs2.Next()) {
-                Handle(StepShape_ShapeDefinitionRepresentation) SDR2 = 
-                  Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs2.Value());
-                if(!SDR2.IsNull()) IsRoot = Standard_False;
-                //else {
-                //  if(SR==SRR->Rep2()) IsRoot = Standard_False;
-                //}
+              if(!SR2.IsNull())
+              {
+                Interface_EntityIterator subs2 = graph.Sharings(SR2);
+                for(subs2.Start(); subs2.More(); subs2.Next()) {
+                  Handle(StepShape_ShapeDefinitionRepresentation) SDR2 = 
+                    Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs2.Value());
+                  if(!SDR2.IsNull()) IsRoot = Standard_False;
+                  //else {
+                  //  if(SR==SRR->Rep2()) IsRoot = Standard_False;
+                  //}
+                }
               }
             }
           }
diff --git a/tests/bugs/step/bug27404 b/tests/bugs/step/bug27404
new file mode 100755 (executable)
index 0000000..096bda0
--- /dev/null
@@ -0,0 +1,14 @@
+puts "============"
+puts "OCC27404"
+puts "============"
+puts ""
+#######################################################################
+# Data Exchange - access violation when reading STEP file
+#######################################################################
+
+param read.step.product.mode 0
+newmodel
+
+XNewDoc D
+
+ReadStep D [locate_data_file bug27404_pmi.stp]