From: mpv Date: Fri, 30 Aug 2019 06:44:35 +0000 (+0300) Subject: Fix for the issue Crash on export file if name of resulting file contain the name... X-Git-Tag: VEDF2019Lot4~22 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=97c9be632393af43d33a6af12b400e95bb69acb5;p=modules%2Fshaper.git Fix for the issue Crash on export file if name of resulting file contain the name of extension (_brep or _step) --- diff --git a/src/ExchangePlugin/ExchangePlugin_Validators.cpp b/src/ExchangePlugin/ExchangePlugin_Validators.cpp index 3f52e2cf1..33464e087 100644 --- a/src/ExchangePlugin/ExchangePlugin_Validators.cpp +++ b/src/ExchangePlugin/ExchangePlugin_Validators.cpp @@ -87,9 +87,10 @@ bool ExchangePlugin_FormatValidator::isValid(const AttributePtr& theAttribute, std::transform(aFileName.begin(), aFileName.end(), aFileName.begin(), toupper); // Is file name ends with the format for (; itFormats != aFormats.end(); ++itFormats) { - if (aFileNameLen > (*itFormats).length()) { - size_t aFormatBeginPos = aFileNameLen - (*itFormats).length(); - if (aFileName.compare(aFormatBeginPos, std::string::npos, *itFormats) == 0) { + std::string aFormat = "." + *itFormats; + if (aFileNameLen > aFormat.length()) { + size_t aFormatBeginPos = aFileNameLen - aFormat.length(); + if (aFileName.compare(aFormatBeginPos, std::string::npos, aFormat) == 0) { return true; } } diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Tools.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Tools.cpp index 9f7f5ec78..55e1e6df9 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Tools.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Tools.cpp @@ -45,6 +45,8 @@ std::string File_Tools::extension(const std::string& theFileName) TCollection_AsciiString aFileName(theFileName.c_str()); OSD_Path aPath(aFileName); TCollection_AsciiString anExtension = aPath.Extension(); + if (anExtension.Length() < 2) + return ""; // TCollection_AsciiString are numbered from 1 anExtension = anExtension.SubString(2, anExtension.Length()); anExtension.UpperCase();