Merge bitcoin/bitcoin#35213: [28.x] validation: correct lifetime of precomputed tx data

076629a3c1 validation: correct lifetime of precomputed tx data (Antoine Poinsot)

Pull request description:

  This backports #35209 to the version 28 branch.

ACKs for top commit:
  achow101:
    ACK 076629a3c1

Tree-SHA512: b8fbf38a80c82abc1648446b05d15f1e04d3f067a50d583074d969ff5a509272691c4c469217e14d86245f63de1ae78efa7bf66c2dd031895373419be155d4e3
This commit is contained in:
Ava Chow
2026-05-06 02:34:03 -07:00

View File

@@ -2603,8 +2603,8 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
// in multiple threads). Preallocate the vector size so a new allocation
// doesn't invalidate pointers into the vector, and keep txsdata in scope
// for as long as `control`.
CCheckQueueControl<CScriptCheck> control(fScriptChecks && parallel_script_checks ? &m_chainman.GetCheckQueue() : nullptr);
std::vector<PrecomputedTransactionData> txsdata(block.vtx.size());
CCheckQueueControl<CScriptCheck> control(fScriptChecks && parallel_script_checks ? &m_chainman.GetCheckQueue() : nullptr);
std::vector<int> prevheights;
CAmount nFees = 0;