mirror of
https://github.com/boostorg/functional.git
synced 2025-07-31 13:07:18 +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
|
try
|
||||||
{
|
{
|
||||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
return make_pointer(
|
new(memory) value_type(BOOST_PP_ENUM_PARAMS(N,a));
|
||||||
new(memory) value_type(BOOST_PP_ENUM_PARAMS(N,a)),
|
|
||||||
boost::non_type<factory_alloc_propagation,AP>() );
|
|
||||||
#else
|
#else
|
||||||
allocator_traits::construct(this->get_allocator(), memory
|
allocator_traits::construct(this->get_allocator(), memory
|
||||||
BOOST_PP_ENUM_TRAILING_PARAMS(N,a));
|
BOOST_PP_ENUM_TRAILING_PARAMS(N,a));
|
||||||
return make_pointer(memory, boost::non_type<factory_alloc_propagation,AP>());
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
@ -206,6 +203,8 @@ namespace boost
|
|||||||
#endif
|
#endif
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return make_pointer(memory, boost::non_type<factory_alloc_propagation,AP>());
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
# undef N
|
# undef N
|
||||||
|
Reference in New Issue
Block a user