summaryrefslogtreecommitdiff
path: root/src/string.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/string.cc')
-rw-r--r--src/string.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/string.cc b/src/string.cc
index 1ab56481..f14abddb 100644
--- a/src/string.cc
+++ b/src/string.cc
@@ -43,6 +43,9 @@ String::Data::Data(Data&& other) noexcept
String::Data& String::Data::operator=(const Data& other)
{
+ if (&other == this)
+ return *this;
+
const size_t new_size = other.size();
reserve<false>(new_size);
memcpy(data(), other.data(), new_size+1);
@@ -53,6 +56,9 @@ String::Data& String::Data::operator=(const Data& other)
String::Data& String::Data::operator=(Data&& other) noexcept
{
+ if (&other == this)
+ return *this;
+
release();
if (other.is_long())