mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:57:43 +00:00
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
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
Add a link
Reference in a new issue