consensus: Fix a rare crash bug
Fix a rare crash bug where no best chain can be activated, and therefore when trying to find the height of the best chain via the last block triggers a null pointer dereference.
This commit is contained in:
parent
1d2380df56
commit
14a2e1ba96
|
@ -2573,7 +2573,11 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
|
|||
}
|
||||
|
||||
} while (pindexNewTip != pindexMostWork);
|
||||
CheckBlockIndex(chainparams.GetConsensus(pindexNewTip->nHeight));
|
||||
if (pindexNewTip != NULL) {
|
||||
CheckBlockIndex(chainparams.GetConsensus(pindexNewTip->nHeight));
|
||||
} else {
|
||||
CheckBlockIndex(chainparams.GetConsensus(0));
|
||||
}
|
||||
|
||||
// Write changes periodically to disk, after relay.
|
||||
if (!FlushStateToDisk(state, FLUSH_STATE_PERIODIC)) {
|
||||
|
|
Loading…
Reference in a new issue