Fix incorrect memory free order in prot_shrink_to_fit_small, fixing a potential memory leak

This commit is contained in:
Ion Gaztañaga
2024-06-03 00:14:00 +02:00
parent c7702d20eb
commit dad179ddf5

View File

@@ -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());