diff options
| author | Gregory Maxwell <[email protected]> | 2012-10-24 01:41:52 -0400 |
|---|---|---|
| committer | Luke Dashjr <[email protected]> | 2012-11-12 22:44:29 +0000 |
| commit | 2d2e5bdcf46d3b4b50d07edb2e010cf7e1cde1b1 (patch) | |
| tree | fbc62cbd3d0adf68ec3953ac6988398bd7329197 /src/main.cpp | |
| parent | Avoid crashes at shutdown due to printf() in global destructors. (diff) | |
| download | discoin-2d2e5bdcf46d3b4b50d07edb2e010cf7e1cde1b1.tar.xz discoin-2d2e5bdcf46d3b4b50d07edb2e010cf7e1cde1b1.zip | |
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)
Diffstat (limited to 'src/main.cpp')
| -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 26adbf717..e740d8e31 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 |