From 43c0257871e2f4a5d533c059f197a635a58361f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 1 Dec 2018 12:58:54 +0100 Subject: [PATCH] Fixes issue #93 --- doc/container.qbk | 1 + include/boost/container/vector.hpp | 9 +-------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/doc/container.qbk b/doc/container.qbk index 6d065fb..3e1b2e6 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -1263,6 +1263,7 @@ use [*Boost.Container]? There are several reasons for that: * [@https://github.com/boostorg/container/pull/86 GitHub #86: ['"Add missing warning re-enabling include"]]. * [@https://github.com/boostorg/container/issues/89 GitHub #89: ['"UBSAN failures detected in preflight CI PR"]]. * [@https://github.com/boostorg/container/issues/90 GitHub #90: ['"Build fails on clang-5 with libstdc++7-dev (C++17 issue)"]]. + * [@https://github.com/boostorg/container/issues/93 GitHub #93: ['"vector::erase memory leak"]]. [endsect] diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp index 939b62f..b3ff8ed 100644 --- a/include/boost/container/vector.hpp +++ b/include/boost/container/vector.hpp @@ -2413,17 +2413,10 @@ class vector const bool propagate_alloc = allocator_traits_type::propagate_on_container_move_assignment::value; const bool is_propagable_from_x = is_propagable_from(x_alloc, x.m_holder.start(), this_alloc, propagate_alloc); - const bool is_propagable_from_t = is_propagable_from(this_alloc, m_holder.start(), x_alloc, propagate_alloc); - const bool are_both_propagable = is_propagable_from_x && is_propagable_from_t; //Resources can be transferred if both allocators are //going to be equal after this function (either propagated or already equal) - if(are_both_propagable){ - //Destroy objects but retain memory in case x reuses it in the future - this->clear(); - this->m_holder.swap_resources(x.m_holder); - } - else if(is_propagable_from_x){ + if(is_propagable_from_x){ this->clear(); if(BOOST_LIKELY(!!this->m_holder.m_start)) this->m_holder.deallocate(this->m_holder.m_start, this->m_holder.m_capacity);