validation: Check chain tip is non-null in CheckFinalTx
Summary:
...also update comments to remove mention of ::ChainActive()
From: https://github.com/bitcoin/bitcoin/pull/20750#discussion_r579400663
Also, what about passing a const reference instead of a pointer? I
know this is only theoretical, but previously if the tip was nullptr,
then Height() evaluated to -1, now it evaluates to UB
Note: in Bitcoin ABC, there was already a check for active_chain_tip == nullptr, but only for nMedianPastTime. A few lines above we accessed the pointer to get the nHeight without checking first (potential UB introduced in D11191).
This is a backport of core#21055 [1/16]
https://github.com/bitcoin/bitcoin/pull/21055/commits/9da106be4db692fa5db7b4de79f9cf7bfef37075
Test Plan:
cmake -GNinja .. \ -DCMAKE_BUILD_TYPE=Debug \ -DENABLE_SANITIZERS=undefined ninja check check-functional
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Subscribers: Fabien
Differential Revision: https://reviews.bitcoinabc.org/D11205