AK: Fix nullptr dereference in String::matches().
In case cp and mp were never set, we should not try to use them.
This commit is contained in:
parent
e585ed48b0
commit
3e326de8fa
Notes:
sideshowbarker
2024-07-19 13:37:51 +09:00
Author: https://github.com/bugaevc Commit: https://github.com/SerenityOS/serenity/commit/3e326de8fa8 Pull-request: https://github.com/SerenityOS/serenity/pull/227 Reviewed-by: https://github.com/awesomekling
1 changed files with 5 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue