diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2016-11-23 01:09:09 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2016-11-23 01:09:09 +0000 |
| commit | 1ccccbce04f63bf1d96465f8d89cb3b7251a9c3e (patch) | |
| tree | a23554d93f32e1503f9ea24dbe6190ff349622fe /src | |
| parent | fbd32fb5125d99cc765f5e8995e07c67b8902090 (diff) | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/string.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/string.cc b/src/string.cc index 5a229030..18ae5d80 100644 --- a/src/string.cc +++ b/src/string.cc @@ -34,7 +34,7 @@ String::Data::Data(Data&& other) noexcept if (other.is_long()) { l = other.l; - other.s.size = 1; + other.set_empty(); } else s = other.s; @@ -52,6 +52,8 @@ String::Data& String::Data::operator=(const Data& other) String::Data& String::Data::operator=(Data&& other) noexcept { + release(); + if (other.is_long()) { l = other.l; |
