Page MenuHomePhabricator

Merge #11337: Fix code constness in CBlockIndex::GetAncestor() overloads
ClosedPublic

Authored by nakihito on Jun 3 2019, 21:32.

Details

Summary

b4058ed Fix code constness in CBlockIndex::GetAncestor() overloads (Dan Raviv)

Pull request description:

Make the non-const overload of `CBlockIndex::GetAncestor()` reuse the const overload implementation instead of the other way around. This way, the constness of the const overload implementation is guaranteed. The other way around, it was possible to implement the non-const overload in a way which mutates the object, and since that implementation would be called even for const objects (due to the reuse), we would get undefined behavior.

Tree-SHA512: 545a8639bc52502ea06dbd924e8fabec6274fa69b43e3b8966a7987ce4dae6fb2498f623730fde7ed0e47478941c7f8baa2e76a12018134ff7c14c0dfa25ba3a

Backport of Core PR11337
https://github.com/bitcoin/bitcoin/pull/11337

Test Plan
make check
test_runner.py

Diff Detail

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

Event Timeline

Owners added a reviewer: Restricted Owners Package.Jun 3 2019, 21:32
deadalnix requested changes to this revision.Jun 3 2019, 21:41
deadalnix added inline comments.
src/chain.cpp
124 ↗(On Diff #9105)

const_cast

This revision now requires changes to proceed.Jun 3 2019, 21:41

Changed static_cast to const_cast

This revision is now accepted and ready to land.Jun 4 2019, 12:54