Browse Source

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

Brad King 18 years ago
parent
commit
ce2b20361a
3 changed files with 5 additions and 5 deletions
  1. 1 1
      Source/cmFindLibraryCommand.cxx
  2. 1 1
      Source/cmFindPathCommand.cxx
  3. 3 3
      Source/kwsys/SystemTools.cxx

+ 1 - 1
Source/cmFindLibraryCommand.cxx

@@ -186,7 +186,7 @@ std::string cmFindLibraryCommand::FindLibrary(const char* name)
       i != this->SearchPaths.end(); ++i)
     {
     std::string& p = *i;
-    if(p[p.size()-1] != '/')
+    if(p.empty() || p[p.size()-1] != '/')
       {
       p += "/";
       }

+ 1 - 1
Source/cmFindPathCommand.cxx

@@ -106,7 +106,7 @@ bool cmFindPathCommand::InitialPass(std::vector<std::string> const& argsIn)
       i != this->SearchPaths.end(); ++i)
     {
     std::string& p = *i;
-    if(p[p.size()-1] != '/')
+    if(p.empty() || p[p.size()-1] != '/')
       {
       p += "/";
       }

+ 3 - 3
Source/kwsys/SystemTools.cxx

@@ -2117,7 +2117,7 @@ kwsys_stl::string SystemTools
       i != path.end(); ++i)
     {
     kwsys_stl::string& p = *i;
-    if(p[p.size()-1] != '/')
+    if(p.empty() || p[p.size()-1] != '/')
       {
       p += "/";
       }
@@ -2249,7 +2249,7 @@ kwsys_stl::string SystemTools::FindProgram(
       i != path.end(); ++i)
     {
     kwsys_stl::string& p = *i;
-    if(p[p.size()-1] != '/')
+    if(p.empty() || p[p.size()-1] != '/')
       {
       p += "/";
       }
@@ -2341,7 +2341,7 @@ kwsys_stl::string SystemTools
       i != path.end(); ++i)
     {
     kwsys_stl::string& p = *i;
-    if(p[p.size()-1] != '/')
+    if(p.empty() || p[p.size()-1] != '/')
       {
       p += "/";
       }