From cc44c8f143e9ce6e10aeed2f6faf2ca589e910a4 Mon Sep 17 00:00:00 2001 From: NicolasDorier Date: Mon, 5 Sep 2016 15:55:04 +0900 Subject: [PATCH] ContextualCheckBlockHeader should never have pindexPrev to NULL --- src/validation.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/validation.cpp b/src/validation.cpp index fe8f8365be0..a83737377a9 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2973,7 +2973,8 @@ std::vector GenerateCoinbaseCommitment(CBlock& block, const CBloc bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& state, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev, int64_t nAdjustedTime) { - const int nHeight = pindexPrev == NULL ? 0 : pindexPrev->nHeight + 1; + assert(pindexPrev != NULL); + const int nHeight = pindexPrev->nHeight + 1; // Check proof of work if (block.nBits != GetNextWorkRequired(pindexPrev, &block, consensusParams)) return state.DoS(100, false, REJECT_INVALID, "bad-diffbits", false, "incorrect proof of work");