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:
parent
102697e5d0
commit
20f4fdee33
|
@ -3980,6 +3980,10 @@ kwsys_stl::string SystemTools::GetParentDirectory(const char* fileOrDir)
|
||||||
|
|
||||||
bool SystemTools::IsSubDirectory(const char* cSubdir, const char* cDir)
|
bool SystemTools::IsSubDirectory(const char* cSubdir, const char* cDir)
|
||||||
{
|
{
|
||||||
|
if(!*cDir)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
kwsys_stl::string subdir = cSubdir;
|
kwsys_stl::string subdir = cSubdir;
|
||||||
kwsys_stl::string dir = cDir;
|
kwsys_stl::string dir = cDir;
|
||||||
SystemTools::ConvertToUnixSlashes(dir);
|
SystemTools::ConvertToUnixSlashes(dir);
|
||||||
|
|
Loading…
Reference in New Issue