mirror of
https://github.com/boostorg/container.git
synced 2025-08-01 13:34:30 +02:00
Fix stack-use-after-scope error detected by ASAN in "test_upstream_resource".
This commit is contained in:
@@ -230,6 +230,9 @@ struct derived_from_monotonic_buffer_resource
|
||||
|
||||
void test_upstream_resource()
|
||||
{
|
||||
//Allocate buffer first to avoid stack-use-after-scope in monotonic_buffer_resource's destructor
|
||||
const std::size_t BufSz = monotonic_buffer_resource::initial_next_buffer_size;
|
||||
boost::move_detail::aligned_storage<BufSz+block_slist::header_size>::type buf;
|
||||
//Test stores the resource and uses it to allocate memory
|
||||
derived_from_memory_resource dmr;
|
||||
dmr.reset();
|
||||
@@ -240,10 +243,8 @@ void test_upstream_resource()
|
||||
BOOST_TEST(dmbr.current_buffer() == 0);
|
||||
//Test it does not allocate any memory
|
||||
BOOST_TEST(dmr.do_allocate_called == false);
|
||||
const std::size_t BufSz = monotonic_buffer_resource::initial_next_buffer_size;
|
||||
//Now allocate storage, and stub it as the return buffer
|
||||
//Now stub buffer storage it as the return buffer
|
||||
//for "derived_from_memory_resource":
|
||||
boost::move_detail::aligned_storage<BufSz+block_slist::header_size>::type buf;
|
||||
dmr.do_allocate_return = &buf;
|
||||
//Test that allocation uses the upstream_resource()
|
||||
void *addr = dmbr.do_allocate(1u, 1u);
|
||||
|
Reference in New Issue
Block a user