From d4e7f08ef0a454e16fab7609d3ab3904b7134cba Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Fri, 23 Jan 2015 13:14:01 -0500
Subject: [PATCH] Directory: Check opendir return value before using it

In Directory::GetNumberOfFilesInDirectory add a missing check for NULL.

Change-Id: I6946eec913e60f786a419264555ec800f9b34d38
---
 Directory.cxx | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Directory.cxx b/Directory.cxx
index 04b28661..58cea635 100644
--- a/Directory.cxx
+++ b/Directory.cxx
@@ -244,6 +244,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 (kwsys_dirent* d = readdir(dir); d; d = readdir(dir) )
     {
-- 
GitLab