BUG: Looks like std::string changes the result of c_str() call. This fixes potential problems

This commit is contained in:
Andy Cedilnik 2005-04-26 11:31:08 -04:00
parent 3db6752efb
commit d381fbfa38

View File

@ -1222,6 +1222,7 @@ void SystemTools::ConvertToUnixSlashes(kwsys_stl::string& path)
if(!path.empty()) if(!path.empty())
{ {
// if there is a tilda ~ then replace it with HOME // if there is a tilda ~ then replace it with HOME
pathCString = path.c_str();
if(*pathCString == '~') if(*pathCString == '~')
{ {
const char* homeEnv = SystemTools::GetEnv("HOME"); const char* homeEnv = SystemTools::GetEnv("HOME");
@ -1231,6 +1232,7 @@ void SystemTools::ConvertToUnixSlashes(kwsys_stl::string& path)
} }
} }
pathCString = path.c_str();
if (*(pathCString+(path.size()-1)) == '/') if (*(pathCString+(path.size()-1)) == '/')
{ {
path = path.substr(0, path.size()-1); path = path.substr(0, path.size()-1);