diff options
author | MarcoFalke <falke.marco@gmail.com> | 2020-04-27 10:35:32 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2020-05-13 19:58:20 -0400 |
commit | 7777f2a4bb1f9d843bc50a4e35085cfbb2808780 (patch) | |
tree | a4bde70689d7d39b7e551d18ff62260265b8cde8 /src/test/validation_block_tests.cpp | |
parent | fa5ceb25fce2200edf6b8ebfa6d4f01ed6774b95 (diff) |
miner: Avoid stack-use-after-return in validationinterface
This is achieved by switching to a shared_ptr.
Also, switch the validationinterfaces in the tests to use shared_ptrs
for the same reason.
Diffstat (limited to 'src/test/validation_block_tests.cpp')
-rw-r--r-- | src/test/validation_block_tests.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/test/validation_block_tests.cpp b/src/test/validation_block_tests.cpp index c026e0f43d..eed26511dd 100644 --- a/src/test/validation_block_tests.cpp +++ b/src/test/validation_block_tests.cpp @@ -32,7 +32,7 @@ struct MinerTestingSetup : public RegTestingSetup { BOOST_FIXTURE_TEST_SUITE(validation_block_tests, MinerTestingSetup) -struct TestSubscriber : public CValidationInterface { +struct TestSubscriber final : public CValidationInterface { uint256 m_expected_tip; explicit TestSubscriber(uint256 tip) : m_expected_tip(tip) {} @@ -175,8 +175,8 @@ BOOST_AUTO_TEST_CASE(processnewblock_signals_ordering) LOCK(cs_main); initial_tip = ::ChainActive().Tip(); } - TestSubscriber sub(initial_tip->GetBlockHash()); - RegisterValidationInterface(&sub); + auto sub = std::make_shared<TestSubscriber>(initial_tip->GetBlockHash()); + RegisterSharedValidationInterface(sub); // create a bunch of threads that repeatedly process a block generated above at random // this will create parallelism and randomness inside validation - the ValidationInterface @@ -206,10 +206,10 @@ BOOST_AUTO_TEST_CASE(processnewblock_signals_ordering) } SyncWithValidationInterfaceQueue(); - UnregisterValidationInterface(&sub); + UnregisterSharedValidationInterface(sub); LOCK(cs_main); - BOOST_CHECK_EQUAL(sub.m_expected_tip, ::ChainActive().Tip()->GetBlockHash()); + BOOST_CHECK_EQUAL(sub->m_expected_tip, ::ChainActive().Tip()->GetBlockHash()); } /** |