mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-28 05:07:35 +00:00
AK: Fix logic in String::operator>(const String&)
Null strings should not compare greater than non-null strings. Add tests for >, <, >=, and <= comparison involving null strings.
This commit is contained in:
parent
c74f75b910
commit
47e8d58553
Notes:
sideshowbarker
2024-07-17 20:46:54 +09:00
Author: https://github.com/mhjacobson
Commit: 47e8d58553
Pull-request: https://github.com/SerenityOS/serenity/pull/11903
2 changed files with 17 additions and 4 deletions
|
@ -58,10 +58,10 @@ bool String::operator<(const String& other) const
|
|||
|
||||
bool String::operator>(const String& other) const
|
||||
{
|
||||
if (!m_impl)
|
||||
return other.m_impl;
|
||||
|
||||
if (!other.m_impl)
|
||||
return m_impl;
|
||||
|
||||
if (!m_impl)
|
||||
return false;
|
||||
|
||||
return strcmp(characters(), other.characters()) > 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue