Salome HOME
Fix for the issue #593: do not remove naming attribute, but use TNaming_Builder for...
[modules/shaper.git] / src / ExchangePlugin / ExchangePlugin_Validators.cpp
index 16df0a1fe6b5946f4940f14cf3cad44b350882dd..bffd2fa419844ae5bf94b7f050505d62b87e98ac 100644 (file)
@@ -59,9 +59,11 @@ 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) {
-    size_t aFormatBeginPos = aFileNameLen - (*itFormats).length();
-    if (aFileName.compare(aFormatBeginPos, std::string::npos, *itFormats) == 0) {
-      return true;
+    if (aFileNameLen > (*itFormats).length()) {
+      size_t aFormatBeginPos = aFileNameLen - (*itFormats).length();
+      if (aFileName.compare(aFormatBeginPos, std::string::npos, *itFormats) == 0) {
+        return true;
+      }
     }
   }
   return false;