Merge #12477: test: Plug memory leaks and stack-use-after-scope

fadb39c test: Plug memory leaks and stack-use-after-scope (MarcoFalke)

Pull request description:

Tree-SHA512: 7bd6bbba43c7870bbd9732d73ecfc520f21701168e6fb4ad099a08ea5b21d9cd09215e70d22fb92a1af03993204ef89ad74b3e80d9fa5a10831c3e7cf2dd04cd
This commit is contained in:
Wladimir J. van der Laan 2018-02-23 17:16:45 +01:00 committed by pasta
parent 1cf2fff1c4
commit e6a1cc63d1
3 changed files with 13 additions and 9 deletions

View File

@ -37,11 +37,6 @@ static void CoinSelection(benchmark::State& state)
LOCK(wallet.cs_wallet);
while (state.KeepRunning()) {
// Empty wallet.
for (COutput output : vCoins)
delete output.tx;
vCoins.clear();
// Add coins.
for (int i = 0; i < 1000; i++)
addCoin(1000 * COIN, wallet, vCoins);
@ -53,6 +48,12 @@ static void CoinSelection(benchmark::State& state)
assert(success);
assert(nValueRet == 1003 * COIN);
assert(setCoinsRet.size() == 2);
// Empty wallet.
for (COutput& output : vCoins) {
delete output.tx;
}
vCoins.clear();
}
}

View File

@ -406,11 +406,11 @@ BOOST_AUTO_TEST_CASE(test_CheckQueueControl_Locks)
boost::thread_group tg;
std::mutex m;
std::condition_variable cv;
bool has_lock{false};
bool has_tried{false};
bool done{false};
bool done_ack{false};
{
bool has_lock {false};
bool has_tried {false};
bool done {false};
bool done_ack {false};
std::unique_lock<std::mutex> l(m);
tg.create_thread([&]{
CCheckQueueControl<FakeCheck> control(queue.get());

View File

@ -35,6 +35,9 @@ void CConnmanTest::AddNode(CNode& node)
void CConnmanTest::ClearNodes()
{
LOCK(g_connman->cs_vNodes);
for (CNode* node : g_connman->vNodes) {
delete node;
}
g_connman->vNodes.clear();
g_connman->mapSocketToNode.clear();