summaryrefslogtreecommitdiff
path: root/AK/String.cpp
diff options
context:
space:
mode:
authorMatt Jacobson <mhjacobson@me.com>2022-01-14 22:24:34 -0500
committerAndreas Kling <kling@serenityos.org>2022-01-16 11:08:23 +0100
commit47e8d585538ace0ef4b7a52ab303f2385327e199 (patch)
treee98bd7b9871c3694512b6c0b7c5eb9199d18f856 /AK/String.cpp
parentc74f75b910b7f8724b765e19e94048db2e3efcea (diff)
downloadserenity-47e8d585538ace0ef4b7a52ab303f2385327e199.zip
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.
Diffstat (limited to 'AK/String.cpp')
-rw-r--r--AK/String.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/AK/String.cpp b/AK/String.cpp
index 6dec4c1438..b975781de0 100644
--- a/AK/String.cpp
+++ b/AK/String.cpp
@@ -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;