validation: don't try to invalidate genesis block in CChainState::InvalidateBlock
In the block invalidation method (CChainState::InvalidateBlock
), the code for creating the candidate block map assumes that the passed block's previous block (pindex->pprev
) is available and otherwise segfaults due to null-pointer deference in CBlockIndexWorkComparator()
(see analysis by practicalswift in #20914 (closed)), i.e. it doesn't work with the genesis block. Rather than analyzing all possible code paths and implications for this corner case, simply fail early if the genesis block is passed.
Fixes #20914 (closed).