]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Call 'Location' with correct indices only to avoid exception.
authorakl <akl@opencascade.com>
Wed, 24 Apr 2013 13:25:21 +0000 (13:25 +0000)
committerakl <akl@opencascade.com>
Wed, 24 Apr 2013 13:25:21 +0000 (13:25 +0000)
src/SMESH_I/SMESH_NoteBook.cxx

index 0168a96e7ef3db68b9eec1e9cc5ffefeeece906c..a482d86ed2db2260982111d8db8d182b7e34bea8 100644 (file)
@@ -258,10 +258,12 @@ void SMESH_NoteBook::ReplaceVariables()
     // Get the entry of object storing "StringAttribute"
     TCollection_AsciiString & cmdStr = aCmd->GetString();
     TEntry2VarVecMap::iterator ent2varVec;
-    if (int pos = cmdStr.Location( SMESH::TVar::ObjPrefix(), 6, cmdStr.Length() ))
+    Standard_Integer fromIndex = 6;
+    Standard_Integer cmdLen = cmdStr.Length();
+    if ( int pos = (fromIndex <= cmdLen) ? cmdStr.Location( SMESH::TVar::ObjPrefix(), fromIndex, cmdLen ) : 0 )
     {
       TCollection_AsciiString varHolderEntry =
-        cmdStr.SubString( pos + strlen( SMESH::TVar::ObjPrefix() ), cmdStr.Length() );
+        cmdStr.SubString( pos + strlen( SMESH::TVar::ObjPrefix() ), cmdLen );
       ent2varVec = _entry2VarsMap.find( varHolderEntry );
       cmdStr.Split( pos - 1 );
     }