From: akl Date: Wed, 24 Apr 2013 13:25:21 +0000 (+0000) Subject: Call 'Location' with correct indices only to avoid exception. X-Git-Tag: V7_2_0~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=866063cabbbb91db3bc2635d726b061a759e17a2;p=modules%2Fsmesh.git Call 'Location' with correct indices only to avoid exception. --- diff --git a/src/SMESH_I/SMESH_NoteBook.cxx b/src/SMESH_I/SMESH_NoteBook.cxx index 0168a96e7..a482d86ed 100644 --- a/src/SMESH_I/SMESH_NoteBook.cxx +++ b/src/SMESH_I/SMESH_NoteBook.cxx @@ -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 ); }