diff options
author | Gregory Maxwell <greg@xiph.org> | 2012-10-24 01:41:52 -0400 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2012-11-12 22:44:29 +0000 |
commit | 2d2e5bdcf46d3b4b50d07edb2e010cf7e1cde1b1 (patch) | |
tree | fbc62cbd3d0adf68ec3953ac6988398bd7329197 | |
parent | b3f8f6ab9409d3e901d22c09b0346a5a47779496 (diff) | |
download | bitcoin-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.cpp | 3 |
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 |