summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorMaciej <sppmacd@pm.me>2022-12-08 18:30:04 +0100
committerAndreas Kling <kling@serenityos.org>2022-12-09 00:02:53 +0100
commit58f5deba70c0e9d21836fda4b1fee041fef69e16 (patch)
tree1edc7537662f17ba9c2e78b177e2313ae9059cb7 /AK
parent741138c5850d5c32a0558d96a1e6f6f92c70e4b1 (diff)
downloadserenity-58f5deba70c0e9d21836fda4b1fee041fef69e16.zip
AK: Unref old m_data in String's move assignment
We were overridding the data pointer without unreffing it, causing a memory leak when assigning a String.
Diffstat (limited to 'AK')
-rw-r--r--AK/String.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/AK/String.cpp b/AK/String.cpp
index ac443a0ce5..c92c3c54eb 100644
--- a/AK/String.cpp
+++ b/AK/String.cpp
@@ -181,6 +181,9 @@ String::String(String&& other)
String& String::operator=(String&& other)
{
+ if (!is_short_string())
+ m_data->unref();
+
m_data = exchange(other.m_data, nullptr);
return *this;
}