1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:57:43 +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:
Matt Jacobson 2022-01-14 22:24:34 -05:00 committed by Andreas Kling
parent c74f75b910
commit 47e8d58553
2 changed files with 17 additions and 4 deletions

View file

@ -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;