Check for proper index before using it as string subscript.

Nicky 2013-11-26 21:05:56 +01:00
parent 8a14f48def
commit aef1b694e8
1 changed files with 8 additions and 1 deletions

View File

@ -91,7 +91,14 @@ std::string LGGContactSets::getOldFileName()
std::string normalPath=gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "");
//we want to steal the last directory off this one
std::string userNameDir = normalPath.substr(normalPath.find_last_of(gDirUtilp->getDirDelimiter()));
std::string userNameDir;
if( normalPath.size() && std::string::npos != normalPath.find_last_of( gDirUtilp->getDirDelimiter() ) )
userNameDir = normalPath.substr(normalPath.find_last_of(gDirUtilp->getDirDelimiter()));
else
userNameDir = normalPath;
path += userNameDir;
if (!path.empty())