Skip to content

Commit

Permalink
Fix incorrect memory free order in prot_shrink_to_fit_small, fixing a…
Browse files Browse the repository at this point in the history
… potential memory leak
  • Loading branch information
igaztanaga committed Jun 2, 2024
1 parent c7702d2 commit dad179d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions include/boost/container/vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2891,11 +2891,11 @@ class vector
);
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());
Expand Down

0 comments on commit dad179d

Please sign in to comment.