summaryrefslogtreecommitdiff
path: root/AK/String.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'AK/String.cpp')
-rw-r--r--AK/String.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/AK/String.cpp b/AK/String.cpp
index e2d5f3d2c4..d0ca1b4909 100644
--- a/AK/String.cpp
+++ b/AK/String.cpp
@@ -253,9 +253,11 @@ bool String::match_helper(const StringView& mask) const
} else if ((mask_ptr < mask_end) && ((*mask_ptr == *string_ptr) || (*mask_ptr == '?'))) {
mask_ptr++;
string_ptr++;
- } else {
+ } else if ((cp != nullptr) && (mp != nullptr)) {
mask_ptr = mp;
string_ptr = cp++;
+ } else {
+ break;
}
}
@@ -263,8 +265,8 @@ bool String::match_helper(const StringView& mask) const
while ((mask_ptr < mask_end) && (*mask_ptr == '*'))
mask_ptr++;
- // If we 'ate' all of the mask then we match.
- return mask_ptr == mask_end;
+ // If we 'ate' all of the mask and the string then we match.
+ return (mask_ptr == mask_end) && !*string_ptr;
}
}