mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-09-27 18:57:44 +02:00
CBlockIndex: ensure phashBlock is not nullptr before dereferencing
and remove a now-redundant assert preceding a GetBlockHash() caller. This protects against UB here, and in case of failure (which would indicate a consensus bug), the debug log will print bitcoind: chain.h:265: uint256 CBlockIndex::GetBlockHash() const: Assertion `phashBlock != nullptr' failed. Aborted instead of Segmentation fault
This commit is contained in:
@@ -263,6 +263,7 @@ public:
|
||||
|
||||
uint256 GetBlockHash() const
|
||||
{
|
||||
assert(phashBlock != nullptr);
|
||||
return *phashBlock;
|
||||
}
|
||||
|
||||
|
@@ -2263,7 +2263,6 @@ bool CChainState::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
||||
m_blockman.m_dirty_blockindex.insert(pindex);
|
||||
}
|
||||
|
||||
assert(pindex->phashBlock);
|
||||
// add this block to the view's block chain
|
||||
view.SetBestBlock(pindex->GetBlockHash());
|
||||
|
||||
|
Reference in New Issue
Block a user