BUG: Avoid infinite loop at directory tree root
The system tools GetParentDirectory method no longer removes the root path component. This fixes cmSystemTools::FileExistsInParentDirectories to not infinitely loop at when GetParentDirectory stops at the root.
This commit is contained in:
parent
714d2fc04b
commit
13e454f8d3
|
@ -1104,7 +1104,8 @@ std::string cmSystemTools::FileExistsInParentDirectories(const char* fname,
|
|||
SystemTools::ConvertToUnixSlashes(file);
|
||||
std::string dir = directory;
|
||||
SystemTools::ConvertToUnixSlashes(dir);
|
||||
while ( !dir.empty() )
|
||||
std::string prevDir;
|
||||
while(dir != prevDir)
|
||||
{
|
||||
std::string path = dir + "/" + file;
|
||||
if ( SystemTools::FileExists(path.c_str()) )
|
||||
|
@ -1115,6 +1116,7 @@ std::string cmSystemTools::FileExistsInParentDirectories(const char* fname,
|
|||
{
|
||||
break;
|
||||
}
|
||||
prevDir = dir;
|
||||
dir = SystemTools::GetParentDirectory(dir.c_str());
|
||||
}
|
||||
return "";
|
||||
|
|
Loading…
Reference in New Issue