aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Maxwell <greg@xiph.org>2012-10-24 01:41:52 -0400
committerLuke Dashjr <luke-jr+git@utopios.org>2012-11-12 22:44:29 +0000
commit2d2e5bdcf46d3b4b50d07edb2e010cf7e1cde1b1 (patch)
treefbc62cbd3d0adf68ec3953ac6988398bd7329197
parentb3f8f6ab9409d3e901d22c09b0346a5a47779496 (diff)
downloadbitcoin-2d2e5bdcf46d3b4b50d07edb2e010cf7e1cde1b1.tar.xz
Fixes a race condition in CreateNewBlock.
CreateNewBlock was reading pindexBest at the start before taking the lock so it was possible to have the the block content not match the prevheader. (Partial of faff50d129b6d4b9e6397ac989218e83a26ae692)
-rw-r--r--src/main.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 26adbf7178..e740d8e319 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -3032,7 +3032,7 @@ public:
CBlock* CreateNewBlock(CReserveKey& reservekey)
{
- CBlockIndex* pindexPrev = pindexBest;
+ CBlockIndex* pindexPrev;
// Create new block
auto_ptr<CBlock> pblock(new CBlock());
@@ -3054,6 +3054,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
CRITICAL_BLOCK(cs_main)
CRITICAL_BLOCK(cs_mapTransactions)
{
+ pindexPrev = pindexBest;
CTxDB txdb("r");
// Priority order to process transactions