mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Add missing cs_main locks when calling blockToJSON/blockheaderToJSON
This commit is contained in:
13
src/rest.cpp
13
src/rest.cpp
@@ -178,8 +178,11 @@ static bool rest_headers(HTTPRequest* req,
|
||||
}
|
||||
case RF_JSON: {
|
||||
UniValue jsonHeaders(UniValue::VARR);
|
||||
for (const CBlockIndex *pindex : headers) {
|
||||
jsonHeaders.push_back(blockheaderToJSON(pindex));
|
||||
{
|
||||
LOCK(cs_main);
|
||||
for (const CBlockIndex *pindex : headers) {
|
||||
jsonHeaders.push_back(blockheaderToJSON(pindex));
|
||||
}
|
||||
}
|
||||
std::string strJSON = jsonHeaders.write() + "\n";
|
||||
req->WriteHeader("Content-Type", "application/json");
|
||||
@@ -239,7 +242,11 @@ static bool rest_block(HTTPRequest* req,
|
||||
}
|
||||
|
||||
case RF_JSON: {
|
||||
UniValue objBlock = blockToJSON(block, pblockindex, showTxDetails);
|
||||
UniValue objBlock;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
objBlock = blockToJSON(block, pblockindex, showTxDetails);
|
||||
}
|
||||
std::string strJSON = objBlock.write() + "\n";
|
||||
req->WriteHeader("Content-Type", "application/json");
|
||||
req->WriteReply(HTTP_OK, strJSON);
|
||||
|
||||
Reference in New Issue
Block a user