Commit 482c8475 authored by Brad King's avatar Brad King
Browse files

KWSys Directory: Check opendir return value before using it (#15367)

In Directory::GetNumberOfFilesInDirectory add a missing check for NULL.
parent 57622bd1
...@@ -239,6 +239,11 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const kwsys_stl::string& na ...@@ -239,6 +239,11 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const kwsys_stl::string& na
{ {
DIR* dir = opendir(name.c_str()); DIR* dir = opendir(name.c_str());
if (!dir)
{
return 0;
}
unsigned long count = 0; unsigned long count = 0;
for (dirent* d = readdir(dir); d; d = readdir(dir) ) for (dirent* d = readdir(dir); d; d = readdir(dir) )
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment