From 43c99e6a6d2b340f22f78a09ff76e41af6f002c5 Mon Sep 17 00:00:00 2001 From: chris_kohlhoff Date: Thu, 27 Mar 2008 14:16:36 +0000 Subject: [PATCH] Fix double-free error that occurs when an exception is thrown from a handler that has been dispatched (i.e. not posted) through a strand. --- asio/include/asio/detail/strand_service.hpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/asio/include/asio/detail/strand_service.hpp b/asio/include/asio/detail/strand_service.hpp index 76f067a2..42a5752f 100644 --- a/asio/include/asio/detail/strand_service.hpp +++ b/asio/include/asio/detail/strand_service.hpp @@ -427,10 +427,9 @@ public: if (impl->current_handler_ == 0) { // This handler now has the lock, so can be dispatched immediately. - impl->current_handler_ = ptr.get(); + impl->current_handler_ = ptr.release(); lock.unlock(); this->get_io_service().dispatch(invoke_current_handler(*this, impl)); - ptr.release(); } else { @@ -467,10 +466,9 @@ public: if (impl->current_handler_ == 0) { // This handler now has the lock, so can be dispatched immediately. - impl->current_handler_ = ptr.get(); + impl->current_handler_ = ptr.release(); lock.unlock(); this->get_io_service().post(invoke_current_handler(*this, impl)); - ptr.release(); } else {