aboutsummaryrefslogtreecommitdiff
path: root/src/rest.cpp
diff options
context:
space:
mode:
authorpracticalswift <[email protected]>2017-11-06 23:20:43 +0100
committerpracticalswift <[email protected]>2017-11-07 07:17:47 +0100
commita9b6ba0b7cd27a64307987afaab7f60bf9b4a15b (patch)
treee1894306fa0e733ac52c7fb756d09b63b4047fc7 /src/rest.cpp
parentMerge #11607: Add Gitian PGP key: Sjors (diff)
downloaddiscoin-a9b6ba0b7cd27a64307987afaab7f60bf9b4a15b.tar.xz
discoin-a9b6ba0b7cd27a64307987afaab7f60bf9b4a15b.zip
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 4d2cdfdf0..b1fc96bdf 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);