From 6fd4341c10b319399c58d71c4ddeae4417e337d7 Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Thu, 9 Sep 2021 17:17:39 +0200 Subject: Require CBlockIndex::GetBlockPos() to hold mutex cs_main --- src/index/txindex.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/index/txindex.cpp') diff --git a/src/index/txindex.cpp b/src/index/txindex.cpp index e9aeb58194..e1d807f39a 100644 --- a/src/index/txindex.cpp +++ b/src/index/txindex.cpp @@ -59,7 +59,9 @@ bool TxIndex::WriteBlock(const CBlock& block, const CBlockIndex* pindex) // Exclude genesis block transaction because outputs are not spendable. if (pindex->nHeight == 0) return true; - CDiskTxPos pos(pindex->GetBlockPos(), GetSizeOfCompactSize(block.vtx.size())); + CDiskTxPos pos{ + WITH_LOCK(::cs_main, return pindex->GetBlockPos()), + GetSizeOfCompactSize(block.vtx.size())}; std::vector> vPos; vPos.reserve(block.vtx.size()); for (const auto& tx : block.vtx) { -- cgit v1.2.3