From 532663c742150b341de22a65da4fd761da6f497a Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 7 Sep 2010 11:40:44 +0000 Subject: COMMON: Fix edge case for wildcard in matchString svn-id: r52618 --- common/str.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'common') diff --git a/common/str.cpp b/common/str.cpp index 2961a0c61b..4585905d62 100644 --- a/common/str.cpp +++ b/common/str.cpp @@ -691,9 +691,18 @@ bool matchString(const char *str, const char *pat, bool ignoreCase, bool pathMod switch (*pat) { case '*': - // Record pattern / string position for backtracking - p = ++pat; - q = str; + if (*str) { + // Record pattern / string position for backtracking + p = ++pat; + q = str; + } else { + // If we've reached the end of str, we can't backtrack further + // NB: We can't simply check if pat also ended here, because + // the pattern might end with any number of *s. + ++pat; + p = 0; + q = 0; + } // If pattern ended with * -> match if (!*pat) return true; -- cgit v1.2.3