]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for the issue Crash on export file if name of resulting file contain the name...
authormpv <mpv@opencascade.com>
Fri, 30 Aug 2019 06:44:35 +0000 (09:44 +0300)
committermpv <mpv@opencascade.com>
Fri, 30 Aug 2019 06:44:35 +0000 (09:44 +0300)
src/ExchangePlugin/ExchangePlugin_Validators.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Tools.cpp

index 3f52e2cf1023ccd86dc3161e219e459e8555a57e..33464e0874f11c3fe1661a83ae9819b0a0a968d7 100644 (file)
@@ -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;
       }
     }
index 9f7f5ec7848bf162c2355050222202457f16e86d..55e1e6df9c6fbffb88afd952012172ca61b4781a 100644 (file)
@@ -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();