HomePhabricator

Sanity assert GetAncestor() != nullptr where appropriate

Description

Sanity assert GetAncestor() != nullptr where appropriate

Summary:
Add sanity asserts for return value of CBlockIndex::GetAncestor() where appropriate.

In validation.cpp CheckSequenceLocks, check the return value of tip->GetAncestor(maxInputHeight) stored into lp->maxInputBlock. If it ever returns nullptr because the ancestor isn't found, it's going to be a bad bug to keep going, since a LockPoints object with the maxInputBlock member set to nullptr signifies no relative lock time.

In the other places, the added asserts would prevent accidental dereferencing of a null pointer which is undefined behavior.

Co-Authored-By: Aurèle Oulès <aurele@oules.com>
Co-Authored-By: danra <danra@users.noreply.github.com>

This is a backport of core#24804

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D13242

Details

Provenance
Adam Jonas <jonas@chaincode.com>Authored on Oct 21 2019, 17:17
PiRKCommitted on Mar 6 2023, 14:03
PiRKPushed on Mar 6 2023, 14:03
Reviewer
Restricted Project
Differential Revision
D13242: Sanity assert GetAncestor() != nullptr where appropriate
Parents
rABC2cdfcd4967b0: refactor: remove use of boost::algorithm::replace_first
Branches
Unknown
Tags
Unknown