From 89c922e02b745d77e91a9a40f4c500962316443f Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Wed, 3 Jul 2019 17:21:00 -0700 Subject: [PATCH] Fix deallocate in multi_buffer --- CHANGELOG.md | 6 ++++++ include/boost/beast/core/impl/multi_buffer.hpp | 10 ++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90badd68..a067c0bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +Version 262: + +* Fix deallocate in multi_buffer + +-------------------------------------------------------------------------------- + Version 261: * Deduplicate `websocket::read_size_hint` definition diff --git a/include/boost/beast/core/impl/multi_buffer.hpp b/include/boost/beast/core/impl/multi_buffer.hpp index f4dfd1c7..e31a8a36 100644 --- a/include/boost/beast/core/impl/multi_buffer.hpp +++ b/include/boost/beast/core/impl/multi_buffer.hpp @@ -977,10 +977,7 @@ consume(size_type n) noexcept in_pos_ = 0; auto& e = list_.front(); list_.erase(list_.iterator_to(e)); - auto const len = sizeof(e) + e.size(); - e.~element(); - alloc_traits::deallocate(a, - reinterpret_cast(&e), len); + destroy(e); #if BOOST_BEAST_MULTI_BUFFER_DEBUG_CHECK debug_check(); #endif @@ -1183,8 +1180,9 @@ destroy(element& e) { auto a = rebind_type{this->get()}; auto const n = - (sizeof(element) + e.size() + sizeof(align_type) - 1) / - sizeof(align_type); + (sizeof(element) + e.size() + + sizeof(align_type) - 1) / + sizeof(align_type); e.~element(); alloc_traits::deallocate(a, reinterpret_cast(&e), n);