aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2014-11-20 12:43:50 +0100
committerPieter Wuille <pieter.wuille@gmail.com>2014-11-20 12:43:50 +0100
commit34559c7c73e3ce67baea0d88ba74b0988b55142d (patch)
tree9d79bf7b88e9cd81cbe830c2fc3d5410671f9587 /src/main.cpp
parentcca48f69b04462c5c9bfefd34443e0b8401dbd6c (diff)
Make PruneBlockIndexCandidates safer
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 1ba17614df..ac65a4ac2f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1954,9 +1954,11 @@ static void PruneBlockIndexCandidates() {
// Note that we can't delete the current block itself, as we may need to return to it later in case a
// reorganization to a better block fails.
std::set<CBlockIndex*, CBlockIndexWorkComparator>::iterator it = setBlockIndexCandidates.begin();
- while (setBlockIndexCandidates.value_comp()(*it, chainActive.Tip())) {
+ while (it != setBlockIndexCandidates.end() && setBlockIndexCandidates.value_comp()(*it, chainActive.Tip())) {
setBlockIndexCandidates.erase(it++);
}
+ // Either the current tip or a successor of it we're working towards is left in setBlockIndexCandidates.
+ assert(!setBlockIndexCandidates.empty());
}
// Try to make some progress towards making pindexMostWork the active block.
@@ -2007,8 +2009,6 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
}
} else {
PruneBlockIndexCandidates();
- // Either the current tip or a successor of it we're working towards is left in setBlockIndexCandidates.
- assert(!setBlockIndexCandidates.empty());
if (!pindexOldTip || chainActive.Tip()->nChainWork > pindexOldTip->nChainWork) {
// We're in a better position than we were. Return temporarily to release the lock.
fContinue = false;