From deb7f4d474b5ca9f2d43645b9d9fc24032c59566 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Mon, 25 Mar 2013 17:38:50 +0400 Subject: [PATCH] Fix globbing failure when stat call fails --- modules/core/src/glob.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/core/src/glob.cpp b/modules/core/src/glob.cpp index d31dccaf39..c655aa9c1e 100644 --- a/modules/core/src/glob.cpp +++ b/modules/core/src/glob.cpp @@ -111,11 +111,11 @@ static bool isDir(const cv::String& path, DIR* dir) return (attributes != INVALID_FILE_ATTRIBUTES) && ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0); #else - struct stat stat_buf; - stat( path.c_str(), &stat_buf); - int is_dir = S_ISDIR( stat_buf.st_mode); (void)dir; - + struct stat stat_buf; + if (0 != stat( path.c_str(), &stat_buf)) + return false; + int is_dir = S_ISDIR( stat_buf.st_mode); return is_dir != 0; #endif }