From 217550fd35244b12470ed61f72bc98c0b9ae9ba0 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf <neundorf@kde.org> Date: Tue, 21 Aug 2007 15:30:07 -0400 Subject: [PATCH] BUG: fix segfault if FindFiles() is called without actual match pattern (e.g. FILE(GLOB /usr/include) instead of FILE(GLOB /usr/include/* ) #4620 Alex --- Glob.cxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Glob.cxx b/Glob.cxx index 0923fb2..0518132 100644 --- a/Glob.cxx +++ b/Glob.cxx @@ -253,8 +253,9 @@ void Glob::RecurseDirectory(kwsys_stl::string::size_type start, if ( !dir_only || !kwsys::SystemTools::FileIsDirectory(realname.c_str()) ) { - if ( this->Internals->Expressions[ - this->Internals->Expressions.size()-1].find(fname.c_str()) ) + if ( (this->Internals->Expressions.size() > 0) && + this->Internals->Expressions[ + this->Internals->Expressions.size()-1].find(fname.c_str()) ) { this->AddFile(this->Internals->Files, realname.c_str()); } @@ -277,6 +278,12 @@ void Glob::ProcessDirectory(kwsys_stl::string::size_type start, this->RecurseDirectory(start, dir, dir_only); return; } + + if ( start >= this->Internals->Expressions.size() ) + { + return; + } + kwsys::Directory d; if ( !d.Load(dir.c_str()) ) { -- GitLab