mirror of
https://github.com/boostorg/functional.git
synced 2025-07-29 20:17:19 +02:00
Call 'make_pointer' outside of try, catch block
If an exception is thrown in the constructor of a smart pointer, then the smart pointer should handle deallocating the memory. If this was inside the try block, then the catch block would deallocate the memory a second time.
This commit is contained in:
@ -189,13 +189,10 @@ namespace boost
|
||||
try
|
||||
{
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
return make_pointer(
|
||||
new(memory) value_type(BOOST_PP_ENUM_PARAMS(N,a)),
|
||||
boost::non_type<factory_alloc_propagation,AP>() );
|
||||
new(memory) value_type(BOOST_PP_ENUM_PARAMS(N,a));
|
||||
#else
|
||||
allocator_traits::construct(this->get_allocator(), memory
|
||||
BOOST_PP_ENUM_TRAILING_PARAMS(N,a));
|
||||
return make_pointer(memory, boost::non_type<factory_alloc_propagation,AP>());
|
||||
#endif
|
||||
}
|
||||
catch (...) {
|
||||
@ -206,6 +203,8 @@ namespace boost
|
||||
#endif
|
||||
throw;
|
||||
}
|
||||
|
||||
return make_pointer(memory, boost::non_type<factory_alloc_propagation,AP>());
|
||||
}
|
||||
# endif
|
||||
# undef N
|
||||
|
Reference in New Issue
Block a user