mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-07 00:56:14 +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:
committed by
Andreas Kling
parent
e585ed48b0
commit
3e326de8fa
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user