Change CChain::Next() to take reference

To minimize chance of erroneous nullptr dereference, `CChain::Next()`
is changed to take a reference instead of a pointer.
Call sites have been adapted. Notably, NextSyncBlock() now checks
the FindFork() result before calling into Next(), because
the fork lookup may return null.
This commit is contained in:
optout
2026-01-29 12:01:23 +01:00
parent fe2d6e25e0
commit 20b58e281a
7 changed files with 21 additions and 21 deletions

View File

@@ -4711,7 +4711,7 @@ VerifyDBResult CVerifyDB::VerifyDB(
reportDone = percentageDone / 10;
}
m_notifications.progress(_("Verifying blocks…"), percentageDone, false);
pindex = chainstate.m_chain.Next(pindex);
pindex = chainstate.m_chain.Next(*pindex);
CBlock block;
if (!chainstate.m_blockman.ReadBlock(block, *pindex)) {
LogError("Verification error: ReadBlock failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());