Page MenuHomePhabricator

validation: Check chain tip is non-null in CheckFinalTx
ClosedPublic

Authored by PiRK on Mar 17 2022, 08:41.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC184be66e5c3f: 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

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

PiRK requested review of this revision.Mar 17 2022, 08:41
Fabien requested changes to this revision.Mar 17 2022, 09:26
Fabien added a subscriber: Fabien.

wrong commit

This revision now requires changes to proceed.Mar 17 2022, 09:26
PiRK requested review of this revision.Mar 17 2022, 10:07
PiRK edited the summary of this revision. (Show Details)

fixed commit

This revision is now accepted and ready to land.Mar 17 2022, 10:51