1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0031711: Data Exchange - STEPCAFControl_Reader hangs on attached file in an infinite loop

Add check if .step external file is the same main file.
This commit is contained in:
dpasukhi
2020-09-01 10:47:20 +03:00
committed by bugmaster
parent 2fa0e902f0
commit 2547d97917
4 changed files with 49 additions and 1 deletions

View File

@@ -46,6 +46,7 @@
#include <StepBasic_SiUnit.hxx>
#include <StepBasic_SiUnitAndLengthUnit.hxx>
#include <StepBasic_Unit.hxx>
#include <StepBasic_DocumentFile.hxx>
#include <STEPCAFControl_Controller.hxx>
#include <STEPCAFControl_DataMapIteratorOfDataMapOfShapePD.hxx>
#include <STEPCAFControl_DataMapOfPDExternFile.hxx>
@@ -623,8 +624,10 @@ Standard_Boolean STEPCAFControl_Reader::Transfer (STEPControl_Reader &reader,
}
}
// get directory name of the main file
// get file name and directory name of the main file
OSD_Path mainfile(reader.WS()->LoadedFile());
TCollection_AsciiString aMainName;
aMainName = mainfile.Name() + mainfile.Extension();
mainfile.SetName("");
mainfile.SetExtension("");
TCollection_AsciiString dpath;
@@ -674,6 +677,13 @@ Standard_Boolean STEPCAFControl_Reader::Transfer (STEPControl_Reader &reader,
TCollection_AsciiString fullname = OSD_Path::AbsolutePath(dpath, filename);
if (fullname.Length() <= 0) fullname = filename;
// check for not the same file
TCollection_AsciiString aMainFullName = OSD_Path::AbsolutePath(dpath, aMainName);
if (TCollection_AsciiString::IsSameString(aMainFullName,fullname,Standard_False)) {
TP->AddWarning(ExtRefs.DocFile(i), "External reference file is the same main file");
continue; // not a valid extern ref
}
/*
char fullname[1024];
char *mainfile = reader.WS()->LoadedFile();