$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r65206 - trunk/libs/exception/src
From: emil_at_[hidden]
Date: 2010-09-03 03:15:50
Author: emildotchevski
Date: 2010-09-03 03:15:47 EDT (Fri, 03 Sep 2010)
New Revision: 65206
URL: http://svn.boost.org/trac/boost/changeset/65206
Log:
fixing minor memory leak in the non-intrusive MSVC exception_ptr support.
Text files modified: 
   trunk/libs/exception/src/clone_current_exception_msvc.cpp |    18 ++++++++++++++----                      
   1 files changed, 14 insertions(+), 4 deletions(-)
Modified: trunk/libs/exception/src/clone_current_exception_msvc.cpp
==============================================================================
--- trunk/libs/exception/src/clone_current_exception_msvc.cpp	(original)
+++ trunk/libs/exception/src/clone_current_exception_msvc.cpp	2010-09-03 03:15:47 EDT (Fri, 03 Sep 2010)
@@ -3,6 +3,7 @@
 //Distributed under the Boost Software License, Version 1.0. (See accompanying
 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
+//This MSVC-specific cpp file implements non-intrusive cloning of exception objects.
 //Based on an exception_ptr implementation by Anthony Williams.
 
 #ifdef BOOST_NO_EXCEPTIONS
@@ -155,11 +156,20 @@
         {
         assert(src!=0);
         cpp_type_info const & ti=get_cpp_type_info(et);
-        void * dst = malloc(ti.size);
-        if( !dst )
+        if( void * dst = malloc(ti.size) )
+            try
+                {
+                copy_msvc_exception(dst,src,ti);
+                return boost::shared_ptr<void>(dst,exception_object_deleter(et));
+                }
+            catch(
+            ... )
+                {
+                free(dst);
+                throw;
+                }
+        else
             throw std::bad_alloc();
-        copy_msvc_exception(dst,src,ti);
-        return boost::shared_ptr<void>(dst,exception_object_deleter(et));
         }
 
     class