aboutsummaryrefslogtreecommitdiff
path: root/src/rest.cpp
diff options
context:
space:
mode:
authorpracticalswift <practicalswift@users.noreply.github.com>2017-11-06 23:20:43 +0100
committerpracticalswift <practicalswift@users.noreply.github.com>2017-11-07 07:17:47 +0100
commita9b6ba0b7cd27a64307987afaab7f60bf9b4a15b (patch)
treee1894306fa0e733ac52c7fb756d09b63b4047fc7 /src/rest.cpp
parent0cc98763919af6d0859b4b7de7d6cf65cd1d713e (diff)
downloadbitcoin-a9b6ba0b7cd27a64307987afaab7f60bf9b4a15b.tar.xz
Add missing cs_main locks when calling blockToJSON/blockheaderToJSON
Diffstat (limited to 'src/rest.cpp')
-rw-r--r--src/rest.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/rest.cpp b/src/rest.cpp
index 4d2cdfdf08..b1fc96bdf5 100644
--- a/src/rest.cpp
+++ b/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);