Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52293 - trunk/boost/asio/ssl/detail
From: chris_at_[hidden]
Date: 2009-04-09 08:12:51


Author: chris_kohlhoff
Date: 2009-04-09 08:12:50 EDT (Thu, 09 Apr 2009)
New Revision: 52293
URL: http://svn.boost.org/trac/boost/changeset/52293

Log:
Prevent memory leaks when an async SSL operation's completion handler throws.
Fixes #2910.

Text files modified:
   trunk/boost/asio/ssl/detail/openssl_stream_service.hpp | 7 ++++---
   1 files changed, 4 insertions(+), 3 deletions(-)

Modified: trunk/boost/asio/ssl/detail/openssl_stream_service.hpp
==============================================================================
--- trunk/boost/asio/ssl/detail/openssl_stream_service.hpp (original)
+++ trunk/boost/asio/ssl/detail/openssl_stream_service.hpp 2009-04-09 08:12:50 EDT (Thu, 09 Apr 2009)
@@ -21,6 +21,7 @@
 #include <boost/asio/detail/push_options.hpp>
 #include <cstddef>
 #include <climits>
+#include <memory>
 #include <boost/config.hpp>
 #include <boost/noncopyable.hpp>
 #include <boost/function.hpp>
@@ -100,8 +101,8 @@
     Handler handler_;
     void handler_impl(const boost::system::error_code& error, size_t size)
     {
+ std::auto_ptr<io_handler<Stream, Handler> > this_ptr(this);
       handler_(error, size);
- delete this;
     }
   }; // class io_handler
 
@@ -124,8 +125,8 @@
     Handler handler_;
     void handler_impl(const boost::system::error_code& error, size_t)
     {
+ std::auto_ptr<handshake_handler<Stream, Handler> > this_ptr(this);
       handler_(error);
- delete this;
     }
 
   }; // class handshake_handler
@@ -149,8 +150,8 @@
     Handler handler_;
     void handler_impl(const boost::system::error_code& error, size_t)
     {
+ std::auto_ptr<shutdown_handler<Stream, Handler> > this_ptr(this);
       handler_(error);
- delete this;
     }
   }; // class shutdown_handler
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk