aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2010-09-07 11:40:44 +0000
committerWillem Jan Palenstijn2010-09-07 11:40:44 +0000
commit532663c742150b341de22a65da4fd761da6f497a (patch)
tree5f3eb2a7375938be9de8191893fcedb09ece1b18 /common
parent0e80aa708802eb38e45820cbf0efaf6b7c1581fe (diff)
downloadscummvm-rg350-532663c742150b341de22a65da4fd761da6f497a.tar.gz
scummvm-rg350-532663c742150b341de22a65da4fd761da6f497a.tar.bz2
scummvm-rg350-532663c742150b341de22a65da4fd761da6f497a.zip
COMMON: Fix edge case for wildcard in matchString
svn-id: r52618
Diffstat (limited to 'common')
-rw-r--r--common/str.cpp15
1 files changed, 12 insertions, 3 deletions
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;