1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00

0023567: Wrong STEP unit is returned by STEPControl_Reader.FileUnits() function

Fix bug with using of uninitialized variable.
New version of patch: pass unit object to the getSiName() function directly.
Test case for this bug
This commit is contained in:
vsr 2012-11-23 15:44:47 +04:00
parent 4e76d93bf1
commit e9c15c4cec
2 changed files with 40 additions and 24 deletions

View File

@ -433,12 +433,12 @@ void STEPControl_Reader::FileUnits( TColStd_SequenceOfAsciiString& theUnitLength
//purpose :
//=======================================================================
inline static TCollection_AsciiString getSiName(StepBasic_SiUnitName theName,
StepBasic_SiPrefix thePrefix)
inline static TCollection_AsciiString getSiName(const Handle(StepBasic_SiUnit)& theUnit)
{
TCollection_AsciiString aName;
switch (thePrefix) {
if (theUnit->HasPrefix()) {
switch (theUnit->Prefix()) {
case StepBasic_spExa: aName += "exa"; break;
case StepBasic_spPeta: aName += "peta"; break;
case StepBasic_spTera: aName += "tera"; break;
@ -459,8 +459,9 @@ inline static TCollection_AsciiString getSiName(StepBasic_SiUnitName theName,
case StepBasic_spNano :aName += "nano"; break;
default: break;
};
}
switch(theName) {
switch(theUnit->Name()) {
case StepBasic_sunMetre : aName += "metre"; break;
case StepBasic_sunRadian : aName += "radian"; break;
case StepBasic_sunSteradian : aName += "steradian"; break;
@ -540,7 +541,7 @@ Standard_Boolean STEPControl_Reader::findUnits(
continue;
anUnitFact = (!aSiUnit->HasPrefix() ?
1. : STEPConstruct_UnitContext::ConvertSiPrefix(aSiUnit->Prefix()));
aName = getSiName(aSiUnit->Name(), aSiUnit->Prefix());
aName = getSiName(aSiUnit);
}

15
tests/bugs/step/bug23567 Executable file
View File

@ -0,0 +1,15 @@
puts "========================"
puts "OCC23567"
puts "========================"
puts ""
#######################################################################
# Wrong STEP unit is returned by STEPControl_Reader.FileUnits() function
#######################################################################
set info [ stepfileunits [locate_data_file bug23567_a.step] ]
set index1 [lsearch $info metre]
puts ""
if { ${index1} == -1 } {
puts "Error : bad unit"
}