From 482c84759fb6df983d519ca2ac61e3c92c0ae7e3 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 23 Jan 2015 13:14:01 -0500 Subject: KWSys Directory: Check opendir return value before using it (#15367) In Directory::GetNumberOfFilesInDirectory add a missing check for NULL. --- Source/kwsys/Directory.cxx | 5 +++++ 1 file changed, 5 insertions(+) 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) ) { -- cgit v0.12