Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r83198 - in trunk/boost/smart_ptr: . detail
From: pdimov_at_[hidden]
Date: 2013-02-28 03:02:11


Author: pdimov
Date: 2013-02-28 03:02:09 EST (Thu, 28 Feb 2013)
New Revision: 83198
URL: http://svn.boost.org/trac/boost/changeset/83198

Log:
Avoid stack overflow in make_shared. Refs #4256.
Text files modified:
   trunk/boost/smart_ptr/detail/shared_count.hpp | 8 ++++----
   trunk/boost/smart_ptr/make_shared_object.hpp | 4 ++++
   2 files changed, 8 insertions(+), 4 deletions(-)

Modified: trunk/boost/smart_ptr/detail/shared_count.hpp
==============================================================================
--- trunk/boost/smart_ptr/detail/shared_count.hpp (original)
+++ trunk/boost/smart_ptr/detail/shared_count.hpp 2013-02-28 03:02:09 EST (Thu, 28 Feb 2013)
@@ -200,7 +200,7 @@
         }
         catch( ... )
         {
- D()( p ); // delete p
+ D::operator_fn( p ); // delete p
             throw;
         }
 
@@ -210,7 +210,7 @@
 
         if( pi_ == 0 )
         {
- D()( p ); // delete p
+ D::operator_fn( p ); // delete p
             boost::throw_exception( std::bad_alloc() );
         }
 
@@ -286,7 +286,7 @@
         }
         catch(...)
         {
- D()( p );
+ D::operator_fn( p );
 
             if( pi_ != 0 )
             {
@@ -306,7 +306,7 @@
         }
         else
         {
- D()( p );
+ D::operator_fn( p );
             boost::throw_exception( std::bad_alloc() );
         }
 

Modified: trunk/boost/smart_ptr/make_shared_object.hpp
==============================================================================
--- trunk/boost/smart_ptr/make_shared_object.hpp (original)
+++ trunk/boost/smart_ptr/make_shared_object.hpp 2013-02-28 03:02:09 EST (Thu, 28 Feb 2013)
@@ -87,6 +87,10 @@
         destroy();
     }
 
+ static void operator_fn( T* ) // operator() can't be static
+ {
+ }
+
     void * address() BOOST_NOEXCEPT
     {
         return storage_.data_;


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