Bugfix: Make sure Utility::Glob return false if no matching files were found.

This commit is contained in:
Gunnar Beutner 2013-02-03 01:30:19 +01:00
parent 5774792a23
commit 383d2369b1
1 changed files with 5 additions and 0 deletions

View File

@ -483,6 +483,11 @@ bool Utility::Glob(const String& pathSpec, const function<void (const String&)>&
throw_exception(PosixException("glob() failed", errno)); throw_exception(PosixException("glob() failed", errno));
} }
if (gr.gl_pathc == 0) {
globfree(&gr);
return false;
}
size_t left; size_t left;
char **gp; char **gp;
for (gp = gr.gl_pathv, left = gr.gl_pathc; left > 0; gp++, left--) { for (gp = gr.gl_pathv, left = gr.gl_pathc; left > 0; gp++, left--) {