summaryrefslogtreecommitdiffstats
path: root/Source/kwsys/SystemTools.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-04-20 12:42:05 (GMT)
committerBrad King <brad.king@kitware.com>2009-04-20 12:42:05 (GMT)
commit20f4fdee338a202fbabab67d86e05db994c491b1 (patch)
treea5757c64ddd18f3c59cfe66fc797d42ff03d45d6 /Source/kwsys/SystemTools.cxx
parent102697e5d0233c33e64f1a6e3648d030da59fc8a (diff)
downloadCMake-20f4fdee338a202fbabab67d86e05db994c491b1.zip
CMake-20f4fdee338a202fbabab67d86e05db994c491b1.tar.gz
CMake-20f4fdee338a202fbabab67d86e05db994c491b1.tar.bz2
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.
Diffstat (limited to 'Source/kwsys/SystemTools.cxx')
-rw-r--r--Source/kwsys/SystemTools.cxx4
1 files changed, 4 insertions, 0 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 814c417..2dd3213 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -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);