From 866063cabbbb91db3bc2635d726b061a759e17a2 Mon Sep 17 00:00:00 2001 From: akl Date: Wed, 24 Apr 2013 13:25:21 +0000 Subject: [PATCH] Call 'Location' with correct indices only to avoid exception. --- src/SMESH_I/SMESH_NoteBook.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 ); } -- 2.30.2