Page MenuHomePhabricator

CBlockIndex: ensure phashBlock is not nullptr before dereferencing
ClosedPublic

Authored by PiRK on Apr 29 2024, 11:15.

Details

Summary

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: blockindex.h:148: BlockHash CBlockIndex::GetBlockHash() const: Assertion `phashBlock != nullptr' failed.
Aborted

instead of

Segmentation fault

This is a partial backport of core#25349
https://github.com/bitcoin/bitcoin/pull/25349/commits/14aeece462b149eaf0d28a37d55cc169df99b2cb
Depends on D16069

Test Plan

ninja all check-all