diff options
| author | Ross Nicoll <[email protected]> | 2021-07-26 22:40:39 +0100 |
|---|---|---|
| committer | Ross Nicoll <[email protected]> | 2021-08-04 09:30:02 +0100 |
| commit | 14a2e1ba9644d0cc59c1f773d330a8f2674ab54b (patch) | |
| tree | 958e3542853d12a7b6c9d92ca2198abcfe926955 /src/validation.cpp | |
| parent | p2p: Reduce BIP125 replace by fee increment value (diff) | |
| download | discoin-14a2e1ba9644d0cc59c1f773d330a8f2674ab54b.tar.xz discoin-14a2e1ba9644d0cc59c1f773d330a8f2674ab54b.zip | |
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.
Diffstat (limited to 'src/validation.cpp')
| -rw-r--r-- | src/validation.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index 35778a2e7..c81ab3c20 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -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)) { |