summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-01-23 18:14:01 (GMT)
committerBrad King <brad.king@kitware.com>2015-01-23 18:19:07 (GMT)
commit482c84759fb6df983d519ca2ac61e3c92c0ae7e3 (patch)
tree4f478b7fb9042a832a3a7d73ca61db7834ba7461 /Source
parent57622bd19d3fd013038d34f497b106a7e2bfd26d (diff)
downloadCMake-482c84759fb6df983d519ca2ac61e3c92c0ae7e3.zip
CMake-482c84759fb6df983d519ca2ac61e3c92c0ae7e3.tar.gz
CMake-482c84759fb6df983d519ca2ac61e3c92c0ae7e3.tar.bz2
KWSys Directory: Check opendir return value before using it (#15367)
In Directory::GetNumberOfFilesInDirectory add a missing check for NULL.
Diffstat (limited to 'Source')
-rw-r--r--Source/kwsys/Directory.cxx5
1 files changed, 5 insertions, 0 deletions
diff --git a/Source/kwsys/Directory.cxx b/Source/kwsys/Directory.cxx
index 741bcba..7041f7b 100644
--- a/Source/kwsys/Directory.cxx
+++ b/Source/kwsys/Directory.cxx
@@ -239,6 +239,11 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const kwsys_stl::string& na
{
DIR* dir = opendir(name.c_str());
+ if (!dir)
+ {
+ return 0;
+ }
+
unsigned long count = 0;
for (dirent* d = readdir(dir); d; d = readdir(dir) )
{