4320 | @@ -4321,7 +4321,7 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview,
4321 | return error("VerifyDB(): *** coin database inconsistencies found (last %i blocks, %i good transactions before that)\n", ::ChainActive().Height() - pindexFailure->nHeight + 1, nGoodTransactions);
4322 |
4323 | // store block count as we move pindex at check level >= 4
4324 | - int block_count = ::ChainActive().Height() - pindex->nHeight;
4325 | + int block_count = ::ChainActive().Height() - Assert(pindex)->nHeight;
I think this assertion is effectively testing if ::ChainActive().Tip() == nullptr as the other ways of setting pindex all seem to be pindex = pindex->pprev after testing pindex->pprev. Might be better to put the Assert there?
There are other places where we assume ChainActive().Tip() is non-null (ie, we immediately dereference it), but at a quick glance I couldn't assure myself that was actually always true. Might be better to actually make it always true (and add a non-null attribute on the response?).