diff options
author | Brad King <brad.king@kitware.com> | 2015-01-23 18:14:01 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-01-23 18:19:07 (GMT) |
commit | 482c84759fb6df983d519ca2ac61e3c92c0ae7e3 (patch) | |
tree | 4f478b7fb9042a832a3a7d73ca61db7834ba7461 /Source | |
parent | 57622bd19d3fd013038d34f497b106a7e2bfd26d (diff) | |
download | CMake-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.cxx | 5 |
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) ) { |