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

9ad085bd83 validation: correct lifetime of precomputed tx data (Antoine Poinsot)

Pull request description:

  This backports #35209 to the version 29 branch.

ACKs for top commit:
  achow101:
    ACK 9ad085bd83
  theuni:
    ACK 9ad085bd83

Tree-SHA512: e9dd4d43ee348015d3b7b485bef4617c69ad8e0c70589f84a16eb2b1d97bdefd21ce5d72ad6a2d8d25bc90d98f65d53374ca921210cab3b0db773072126459f6
This commit is contained in:
Ava Chow
2026-05-06 01:32:52 -07:00

View File

@@ -2615,8 +2615,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;