Merge pull request #6054 from nuttycom/bug/6044-null_block_pos

Ensure that the node has position information before attempting to read block data.
This commit is contained in:
str4d 2022-07-06 15:52:42 +01:00 committed by GitHub
commit 904528997a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -712,8 +712,8 @@ void ThreadStartWalletNotifier()
// We know we have the genesis block.
assert(pindexFork != nullptr);
if (pindexLastTip->nHeight < pindexFork->nHeight ||
pindexLastTip->nHeight - pindexFork->nHeight < 100)
if ((pindexLastTip->nHeight < pindexFork->nHeight || pindexLastTip->nHeight - pindexFork->nHeight < 100) &&
!pindexLastTip->GetBlockPos().IsNull())
{
break;
}

View File

@ -2241,6 +2241,11 @@ bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos, const Consensus:
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex, const Consensus::Params& consensusParams)
{
if (pindex->GetBlockPos().IsNull()) {
return error("ReadBlockFromDisk(CBlock&, CBlockIndex*): block index entry does not provide a valid disk position for block %s at %s",
pindex->ToString(), pindex->GetBlockPos().ToString());
}
if (!ReadBlockFromDisk(block, pindex->GetBlockPos(), consensusParams))
return false;
if (block.GetHash() != pindex->GetBlockHash())