0030628: [REGRESSION] Data Exchange - Crash on importing STEP file
authorkgv <kgv@opencascade.com>
Thu, 11 Jul 2019 06:38:54 +0000 (09:38 +0300)
committerbugmaster <bugmaster@opencascade.com>
Mon, 15 Jul 2019 12:48:00 +0000 (15:48 +0300)
RWHeaderSection_RWFileDescription::ReadStep(), added check for an empty list.

src/RWHeaderSection/RWHeaderSection_RWFileDescription.cxx
tests/bugs/step/bug30628 [new file with mode: 0644]

index fe45269..98ffe52 100644 (file)
@@ -37,15 +37,17 @@ void RWHeaderSection_RWFileDescription::ReadStep
 
        Handle(Interface_HArray1OfHAsciiString) aDescription;
        Handle(TCollection_HAsciiString) aDescriptionItem;
-       Standard_Integer nsub1;
-       nsub1 = data->SubListNumber(num, 1, Standard_False);
+       Standard_Integer nsub1 = data->SubListNumber(num, 1, Standard_False);
        if (nsub1 !=0) {
          Standard_Integer nb1 = data->NbParams(nsub1);
-         aDescription = new Interface_HArray1OfHAsciiString (1, nb1);
-         for (Standard_Integer i1 = 1; i1 <= nb1; i1 ++) {
-           Standard_Boolean stat1 = data->ReadString
-                (nsub1,i1,"description",ach,aDescriptionItem);
-           if (stat1) aDescription->SetValue(i1,aDescriptionItem);
+         if (nb1 > 0)
+         {
+           aDescription = new Interface_HArray1OfHAsciiString (1, nb1);
+           for (Standard_Integer i1 = 1; i1 <= nb1; i1 ++) {
+             Standard_Boolean stat1 = data->ReadString
+                  (nsub1,i1,"description",ach,aDescriptionItem);
+             if (stat1) aDescription->SetValue(i1,aDescriptionItem);
+           }
          }
        }
        else {
diff --git a/tests/bugs/step/bug30628 b/tests/bugs/step/bug30628
new file mode 100644 (file)
index 0000000..e856650
--- /dev/null
@@ -0,0 +1,12 @@
+puts "# ====================================================================="
+puts "# 0030628: Data Exchange - Crash on importing STEP file"
+puts "# ====================================================================="
+puts ""
+
+vclear
+vinit View1
+vaxo
+ReadStep D [locate_data_file bug30628_319892-GSE306L520-HOG-s5.stp]
+XDisplay D -dispMode 1
+vfit
+vdump ${imagedir}/${casename}.png