Fix horrible leak in String::Data::operator=(String::Data&&)

And that, my friends, is why we recommend using standard containers
instead of rolling your own.
This commit is contained in:
Maxime Coste 2016-11-23 01:09:09 +00:00
parent fbd32fb512
commit 1ccccbce04

View File

@ -34,7 +34,7 @@ String::Data::Data(Data&& other) noexcept
if (other.is_long()) if (other.is_long())
{ {
l = other.l; l = other.l;
other.s.size = 1; other.set_empty();
} }
else else
s = other.s; s = other.s;
@ -52,6 +52,8 @@ String::Data& String::Data::operator=(const Data& other)
String::Data& String::Data::operator=(Data&& other) noexcept String::Data& String::Data::operator=(Data&& other) noexcept
{ {
release();
if (other.is_long()) if (other.is_long())
{ {
l = other.l; l = other.l;