mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 20:32:35 -03: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:
parent
02ede4f1fd
commit
14aeece462
2 changed files with 1 additions and 1 deletions
|
@ -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());
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue