From 5c8caba940c99bc1985b45402c336715e44c6032 Mon Sep 17 00:00:00 2001 From: alandefreitas Date: Fri, 24 Sep 2021 21:17:29 -0300 Subject: [PATCH] Reset on move --- source/small/vector.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/small/vector.h b/source/small/vector.h index 5151605..8c67669 100644 --- a/source/small/vector.h +++ b/source/small/vector.h @@ -223,9 +223,11 @@ namespace small { if (rhs.is_external()) { this->data_.heap_storage_.pointer_ = rhs.data_.heap_storage_.pointer_; + rhs.data_.heap_storage_.pointer_ = nullptr; size_ = rhs.size_; rhs.size_ = 0; this->data_.set_capacity(rhs.data_.get_capacity()); + rhs.data_.set_capacity(0); } else { if (should_copy_inline) { copy_inline_trivial(rhs); @@ -315,10 +317,12 @@ namespace small { } else { // rhs is external this->data_.heap_storage_.pointer_ = rhs.data_.heap_storage_.pointer_; + rhs.data_.heap_storage_.pointer_ = nullptr; // this was already reset above, so it's empty and internal. size_ = rhs.size_; rhs.size_ = 0; this->data_.set_capacity(rhs.data_.get_capacity()); + rhs.data_.set_capacity(0); } } } else {