mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
StringView: operator==(const char*) needs to stop when the view ends.
We were comparing past the end of the view, which was clearly not correct.
This commit is contained in:
parent
f90d75e5b9
commit
de9edb0169
Notes:
sideshowbarker
2024-07-19 13:40:53 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/de9edb01697
1 changed files with 11 additions and 2 deletions
|
@ -38,8 +38,17 @@ public:
|
|||
Vector<StringView> split_view(char) const;
|
||||
unsigned to_uint(bool& ok) const;
|
||||
|
||||
bool operator==(const char* cstring) const { return !strcmp(m_characters, cstring); }
|
||||
bool operator!=(const char* cstring) const { return strcmp(m_characters, cstring); }
|
||||
bool operator==(const char* cstring) const
|
||||
{
|
||||
int other_length = strlen(cstring);
|
||||
if (m_length != other_length)
|
||||
return false;
|
||||
return !memcmp(m_characters, cstring, m_length);
|
||||
}
|
||||
bool operator!=(const char* cstring) const
|
||||
{
|
||||
return !(*this == cstring);
|
||||
}
|
||||
|
||||
bool operator==(const String&) const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue