From dad179ddf5c7998932388f69b4e192b98eed1730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Mon, 3 Jun 2024 00:14:00 +0200 Subject: [PATCH] Fix incorrect memory free order in prot_shrink_to_fit_small, fixing a potential memory leak --- include/boost/container/vector.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp index fa2b444..a6e2f49 100644 --- a/include/boost/container/vector.hpp +++ b/include/boost/container/vector.hpp @@ -2891,11 +2891,11 @@ private: ); boost::container::destroy_alloc_n(this->get_stored_allocator(), oldbuf, sz); - this->m_holder.m_start = small_buffer; - this->m_holder.set_stored_capacity(small_capacity); - if (BOOST_LIKELY(!!this->m_holder.m_start)) this->m_holder.deallocate(this->m_holder.m_start, cp); + + this->m_holder.m_start = small_buffer; + this->m_holder.set_stored_capacity(small_capacity); } else if (sz < cp) { this->priv_move_to_new_buffer(sz, alloc_version());