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:
1 parent
02ede4f1fd
commit
14aeece462
2 files changed
+1
-1
No files matched your search
@@ -263,6 +263,7 @@ public:
|
|||||||
|
|
||||||
uint256 GetBlockHash() const
|
uint256 GetBlockHash() const
|
||||||
{
|
{
|
||||||
|
assert(phashBlock != nullptr);
|
||||||
return *phashBlock;
|
return *phashBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2263,7 +2263,6 @@ bool CChainState::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
|||||||
m_blockman.m_dirty_blockindex.insert(pindex);
|
m_blockman.m_dirty_blockindex.insert(pindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(pindex->phashBlock);
|
|
||||||
// add this block to the view's block chain
|
// add this block to the view's block chain
|
||||||
view.SetBestBlock(pindex->GetBlockHash());
|
view.SetBestBlock(pindex->GetBlockHash());
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user