Merged revision(s) 83198 from trunk: Avoid stack overflow in make_shared. Fixes #4256. Fixes #7965.

[SVN r83341]
This commit is contained in:
Peter Dimov
2013-03-07 08:18:48 +00:00
parent 3178d38137
commit 579b347267
2 changed files with 8 additions and 4 deletions

View File

@@ -200,7 +200,7 @@ public:
} }
catch( ... ) catch( ... )
{ {
D()( p ); // delete p D::operator_fn( p ); // delete p
throw; throw;
} }
@@ -210,7 +210,7 @@ public:
if( pi_ == 0 ) if( pi_ == 0 )
{ {
D()( p ); // delete p D::operator_fn( p ); // delete p
boost::throw_exception( std::bad_alloc() ); boost::throw_exception( std::bad_alloc() );
} }
@@ -286,7 +286,7 @@ public:
} }
catch(...) catch(...)
{ {
D()( p ); D::operator_fn( p );
if( pi_ != 0 ) if( pi_ != 0 )
{ {
@@ -306,7 +306,7 @@ public:
} }
else else
{ {
D()( p ); D::operator_fn( p );
boost::throw_exception( std::bad_alloc() ); boost::throw_exception( std::bad_alloc() );
} }

View File

@@ -87,6 +87,10 @@ public:
destroy(); destroy();
} }
static void operator_fn( T* ) // operator() can't be static
{
}
void * address() BOOST_NOEXCEPT void * address() BOOST_NOEXCEPT
{ {
return storage_.data_; return storage_.data_;