From f5ff3d773c2f781016b6b047ea8d4aa029756544 Mon Sep 17 00:00:00 2001 From: Andrew Toth Date: Wed, 26 Oct 2022 11:46:39 -0400 Subject: [PATCH] rpc: add missing lock around chainman.ActiveTip() --- src/rpc/blockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 39ee95b939..bc1028aec3 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -461,7 +461,7 @@ static RPCHelpMan getblockfrompeer() // Fetching blocks before the node has syncing past their height can prevent block files from // being pruned, so we avoid it if the node is in prune mode. - if (index->nHeight > chainman.ActiveChain().Tip()->nHeight && node::fPruneMode) { + if (node::fPruneMode && index->nHeight > WITH_LOCK(chainman.GetMutex(), return chainman.ActiveTip()->nHeight)) { throw JSONRPCError(RPC_MISC_ERROR, "In prune mode, only blocks that the node has already synced previously can be fetched from a peer"); }