From afc1dd4f6b0ff1768b3e3565b2db5c3bfb182259 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Mon, 11 Mar 2013 18:09:33 +0100 Subject: api: fix bug in string_match when mask begins and ends with "*" The bug was string_match returning 0 (instead of 1) if mask begins and ends with "*" and if string and mask have same length (except both "*") with same content: string_match("abc", "*abc*", 0) == 0 // BUG: it should return 1 string_match("abcd", "*abc*", 0) == 1 // OK --- src/core/wee-string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/core/wee-string.c b/src/core/wee-string.c index 4b3b255c7..443f22f02 100644 --- a/src/core/wee-string.c +++ b/src/core/wee-string.c @@ -412,7 +412,7 @@ string_match (const char *string, const char *mask, int case_sensitive) if ((mask[0] == '*') && (last == '*')) { /* not enough chars in string to match */ - if (len_string < len_mask - 1) + if (len_string < len_mask - 2) return 0; /* keep only relevant chars in mask for searching string */ mask2 = string_strndup (mask + 1, len_mask - 2); -- cgit v1.2.3