BUG: Fix SystemTools::IsSubDirectory on bad input

When SystemTools::GetParentDirectory was fixed to never remove the root
path component from a full path we violated an assumption made by
IsSubDirectory that eventually GetParentDirectory returns an empty
string.  This led to an infinite loop if the potential parent directory
is empty, so we explicitly avoid that case.
This commit is contained in:
Brad King 2009-04-20 08:42:05 -04:00
parent 102697e5d0
commit 20f4fdee33
1 changed files with 4 additions and 0 deletions

View File

@ -3980,6 +3980,10 @@ kwsys_stl::string SystemTools::GetParentDirectory(const char* fileOrDir)
bool SystemTools::IsSubDirectory(const char* cSubdir, const char* cDir)
{
if(!*cDir)
{
return false;
}
kwsys_stl::string subdir = cSubdir;
kwsys_stl::string dir = cDir;
SystemTools::ConvertToUnixSlashes(dir);