aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xt/t3070-wildmatch.sh2
-rw-r--r--wildmatch.c3
2 files changed, 3 insertions, 2 deletions
diff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh
index d5bafefbe..af54c8311 100755
--- a/t/t3070-wildmatch.sh
+++ b/t/t3070-wildmatch.sh
@@ -83,7 +83,7 @@ match 0 0 'deep/foo/bar/baz/' '**/bar/*'
match 1 0 'deep/foo/bar/baz/' '**/bar/**'
match 0 0 'deep/foo/bar' '**/bar/*'
match 1 0 'deep/foo/bar/' '**/bar/**'
-match 1 0 'foo/bar/baz' '**/bar**'
+match 0 0 'foo/bar/baz' '**/bar**'
match 1 0 'foo/bar/baz/x' '*/bar/**'
match 0 0 'deep/foo/bar/baz/x' '*/bar/**'
match 1 0 'deep/foo/bar/baz/x' '**/bar/*/*'
diff --git a/wildmatch.c b/wildmatch.c
index 3972e26e8..5f976e91d 100644
--- a/wildmatch.c
+++ b/wildmatch.c
@@ -58,6 +58,7 @@ typedef unsigned char uchar;
static int dowild(const uchar *p, const uchar *text, int force_lower_case)
{
uchar p_ch;
+ const uchar *pattern = p;
for ( ; (p_ch = *p) != '\0'; text++, p++) {
int matched, special;
@@ -87,7 +88,7 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
if (*++p == '*') {
const uchar *prev_p = p - 2;
while (*++p == '*') {}
- if ((prev_p == text || *prev_p == '/') ||
+ if ((prev_p < pattern || *prev_p == '/') &&
(*p == '\0' || *p == '/' ||
(p[0] == '\\' && p[1] == '/'))) {
/*