aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-12-08 22:26:27 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-12-08 22:26:27 +0000
commitdfbb85b6fef5daf26d5c1359245dec71606e6076 (patch)
tree0a2938168d8010aaab8139f97f1205ca9fda2cdf /src
parentMerge pull request #1403 (diff)
downloadmonero-dfbb85b6fef5daf26d5c1359245dec71606e6076.tar.xz
blockchain: fix setting non trovial alternate chain as invalid
The wrong iterator was being used. Also preincrement iterators to avoid possibly invalidating them, I'm not sure this is necessary, but let's be safe.
Diffstat (limited to 'src')
-rw-r--r--src/cryptonote_core/blockchain.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index df9c0f3f3..df24204f8 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -832,12 +832,12 @@ bool Blockchain::switch_to_alternative_blockchain(std::list<blocks_ext_by_hash::
// looking into.
add_block_as_invalid(ch_ent->second, get_block_hash(ch_ent->second.bl));
LOG_PRINT_L1("The block was inserted as invalid while connecting new alternative chain, block_id: " << get_block_hash(ch_ent->second.bl));
- m_alternative_chains.erase(ch_ent);
+ m_alternative_chains.erase(*alt_ch_iter++);
- for(auto alt_ch_to_orph_iter = ++alt_ch_iter; alt_ch_to_orph_iter != alt_chain.end(); alt_ch_to_orph_iter++)
+ for(auto alt_ch_to_orph_iter = alt_ch_iter; alt_ch_to_orph_iter != alt_chain.end(); )
{
- add_block_as_invalid((*alt_ch_iter)->second, (*alt_ch_iter)->first);
- m_alternative_chains.erase(*alt_ch_to_orph_iter);
+ add_block_as_invalid((*alt_ch_to_orph_iter)->second, (*alt_ch_to_orph_iter)->first);
+ m_alternative_chains.erase(*alt_ch_to_orph_iter++);
}
return false;
}