From 7a702c4e86347d50f04a8768ff2c4832777e2d57 Mon Sep 17 00:00:00 2001 From: Saliya Hamparawa Date: Wed, 20 Dec 2017 11:09:38 +0530 Subject: [PATCH] Fixing a resource leak in move assignment Signed-off-by: Saliya Hamparawa --- include/boost/coroutine2/detail/pull_coroutine.hpp | 3 +-- include/boost/coroutine2/detail/push_coroutine.hpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/include/boost/coroutine2/detail/pull_coroutine.hpp b/include/boost/coroutine2/detail/pull_coroutine.hpp index 32cd68e..ab90b60 100644 --- a/include/boost/coroutine2/detail/pull_coroutine.hpp +++ b/include/boost/coroutine2/detail/pull_coroutine.hpp @@ -56,8 +56,7 @@ public: pull_coroutine & operator=( pull_coroutine && other) noexcept { if ( this == & other) return * this; - cb_ = other.cb_; - other.cb_ = nullptr; + std::swap(cb_, other.cb_); return * this; } diff --git a/include/boost/coroutine2/detail/push_coroutine.hpp b/include/boost/coroutine2/detail/push_coroutine.hpp index d152be2..4b183a7 100644 --- a/include/boost/coroutine2/detail/push_coroutine.hpp +++ b/include/boost/coroutine2/detail/push_coroutine.hpp @@ -54,8 +54,7 @@ public: push_coroutine & operator=( push_coroutine && other) noexcept { if ( this == & other) return * this; - cb_ = other.cb_; - other.cb_ = nullptr; + std::swap(cb_, other.cb_); return * this; }