Commit ce2b2036 authored by Brad King's avatar Brad King
Browse files

BUG: Fix previous commit to not access empty strings out of bounds.

parent 9f982d7d
...@@ -186,7 +186,7 @@ std::string cmFindLibraryCommand::FindLibrary(const char* name) ...@@ -186,7 +186,7 @@ std::string cmFindLibraryCommand::FindLibrary(const char* name)
i != this->SearchPaths.end(); ++i) i != this->SearchPaths.end(); ++i)
{ {
std::string& p = *i; std::string& p = *i;
if(p[p.size()-1] != '/') if(p.empty() || p[p.size()-1] != '/')
{ {
p += "/"; p += "/";
} }
......
...@@ -106,7 +106,7 @@ bool cmFindPathCommand::InitialPass(std::vector<std::string> const& argsIn) ...@@ -106,7 +106,7 @@ bool cmFindPathCommand::InitialPass(std::vector<std::string> const& argsIn)
i != this->SearchPaths.end(); ++i) i != this->SearchPaths.end(); ++i)
{ {
std::string& p = *i; std::string& p = *i;
if(p[p.size()-1] != '/') if(p.empty() || p[p.size()-1] != '/')
{ {
p += "/"; p += "/";
} }
......
...@@ -2117,7 +2117,7 @@ kwsys_stl::string SystemTools ...@@ -2117,7 +2117,7 @@ kwsys_stl::string SystemTools
i != path.end(); ++i) i != path.end(); ++i)
{ {
kwsys_stl::string& p = *i; kwsys_stl::string& p = *i;
if(p[p.size()-1] != '/') if(p.empty() || p[p.size()-1] != '/')
{ {
p += "/"; p += "/";
} }
...@@ -2249,7 +2249,7 @@ kwsys_stl::string SystemTools::FindProgram( ...@@ -2249,7 +2249,7 @@ kwsys_stl::string SystemTools::FindProgram(
i != path.end(); ++i) i != path.end(); ++i)
{ {
kwsys_stl::string& p = *i; kwsys_stl::string& p = *i;
if(p[p.size()-1] != '/') if(p.empty() || p[p.size()-1] != '/')
{ {
p += "/"; p += "/";
} }
...@@ -2341,7 +2341,7 @@ kwsys_stl::string SystemTools ...@@ -2341,7 +2341,7 @@ kwsys_stl::string SystemTools
i != path.end(); ++i) i != path.end(); ++i)
{ {
kwsys_stl::string& p = *i; kwsys_stl::string& p = *i;
if(p[p.size()-1] != '/') if(p.empty() || p[p.size()-1] != '/')
{ {
p += "/"; p += "/";
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment