From 2fb08f01328b927059a69290abf1d0c5559e9ed9 Mon Sep 17 00:00:00 2001 From: kgv Date: Thu, 11 Jul 2019 09:38:54 +0300 Subject: [PATCH] 0030628: [REGRESSION] Data Exchange - Crash on importing STEP file RWHeaderSection_RWFileDescription::ReadStep(), added check for an empty list. --- .../RWHeaderSection_RWFileDescription.cxx | 16 +++++++++------- tests/bugs/step/bug30628 | 12 ++++++++++++ 2 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 tests/bugs/step/bug30628 diff --git a/src/RWHeaderSection/RWHeaderSection_RWFileDescription.cxx b/src/RWHeaderSection/RWHeaderSection_RWFileDescription.cxx index fe4526924c..98ffe52150 100644 --- a/src/RWHeaderSection/RWHeaderSection_RWFileDescription.cxx +++ b/src/RWHeaderSection/RWHeaderSection_RWFileDescription.cxx @@ -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 index 0000000000..e856650c5a --- /dev/null +++ b/tests/bugs/step/bug30628 @@ -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