diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-09-20 19:02:23 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-09-20 19:07:40 +0200 |
commit | 551d7bf604fb4615d64b8b644aefa160dadc34c4 (patch) | |
tree | 99579b021c56fd230fa2eed5880015e56714befd /src/validation.cpp | |
parent | 28474802758a92d5f985302fc85bbb691263f06a (diff) | |
parent | fdc329376c8a0fa4dffd0cd2599a494a64c38472 (diff) | |
download | bitcoin-551d7bf604fb4615d64b8b644aefa160dadc34c4.tar.xz |
Merge #11132: Document assumptions that are being made to avoid NULL pointer dereferences
fdc3293 Document assumptions that are being made to avoid NULL pointer dereferences (practicalswift)
Pull request description:
Document assumptions (via `assert(…)`:s) that are being made avoid `NULL` pointer dereferences.
Rationale:
* Make it clear to human reviewers and non-human static analyzers that what might look like potential `NULL` pointer dereferences are written the way they are intentionally (these cases are currently flagged by various static analyzers).
Tree-SHA512: b424328195e2680e1e4ec546298f718c49e5ad182147dc004de580693db1b50eec4065e1c4f232bdb302baa12954265a50ba21cb5ba4ff30248535b2de778672
Diffstat (limited to 'src/validation.cpp')
-rw-r--r-- | src/validation.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index 12ffe085d7..85a6af8585 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1711,6 +1711,7 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd // before the first had been spent. Since those coinbases are sufficiently buried its no longer possible to create further // duplicate transactions descending from the known pairs either. // If we're on the known chain at height greater than where BIP34 activated, we can save the db accesses needed for the BIP30 check. + assert(pindex->pprev); CBlockIndex *pindexBIP34height = pindex->pprev->GetAncestor(chainparams.GetConsensus().BIP34Height); //Only continue to enforce if we're below BIP34 activation height or the block hash at that height doesn't correspond. fEnforceBIP30 = fEnforceBIP30 && (!pindexBIP34height || !(pindexBIP34height->GetBlockHash() == chainparams.GetConsensus().BIP34Hash)); @@ -1850,6 +1851,7 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd if (!pblocktree->WriteTxIndex(vPos)) return AbortNode(state, "Failed to write transaction index"); + assert(pindex->phashBlock); // add this block to the view's block chain view.SetBestBlock(pindex->GetBlockHash()); |