From d0451abf1a95fbd988fd96ad6b51d78c102bfc8c Mon Sep 17 00:00:00 2001 From: Artyom Kolpakov Date: Wed, 3 Sep 2025 08:41:38 +0300 Subject: [PATCH 1/2] Fix resource leak in `awaitable::operator=` `awaitable::operator=` did not destroy the existing frame --- include/boost/asio/awaitable.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/boost/asio/awaitable.hpp b/include/boost/asio/awaitable.hpp index 43f80cf48..f808f27a2 100644 --- a/include/boost/asio/awaitable.hpp +++ b/include/boost/asio/awaitable.hpp @@ -80,8 +80,11 @@ class BOOST_ASIO_NODISCARD awaitable /// Move assignment. awaitable& operator=(awaitable&& other) noexcept { - if (this != &other) + if (this != &other) { + if (frame_) + frame_->destroy(); frame_ = std::exchange(other.frame_, nullptr); + } return *this; } From a3a0d569fef92e7b974fcf5da58671216941d89b Mon Sep 17 00:00:00 2001 From: Artyom Kolpakov Date: Wed, 3 Sep 2025 09:08:38 +0300 Subject: [PATCH 2/2] Fix formatting --- include/boost/asio/awaitable.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/boost/asio/awaitable.hpp b/include/boost/asio/awaitable.hpp index f808f27a2..1ed3ac25d 100644 --- a/include/boost/asio/awaitable.hpp +++ b/include/boost/asio/awaitable.hpp @@ -80,7 +80,8 @@ class BOOST_ASIO_NODISCARD awaitable /// Move assignment. awaitable& operator=(awaitable&& other) noexcept { - if (this != &other) { + if (this != &other) + { if (frame_) frame_->destroy(); frame_ = std::exchange(other.frame_, nullptr);