aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@exmulti.com>2012-05-14 01:11:11 -0400
committerLuke Dashjr <luke-jr+git@utopios.org>2012-05-18 00:04:18 +0000
commit3a05f1d2ce45d5d9fbbd7b1b897f3c6e32f58720 (patch)
treee07da06cc41a5c7e2116d0e6eb1ce76779ad15f9 /src/main.cpp
parent0d174e130b8e89e6de9517d24498615d18d8f382 (diff)
downloadbitcoin-3a05f1d2ce45d5d9fbbd7b1b897f3c6e32f58720.tar.xz
Always check return values of TxnBegin() and TxnCommit()
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 7e4ed1100c..f13f6165b3 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1496,7 +1496,9 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew)
{
uint256 hash = GetHash();
- txdb.TxnBegin();
+ if (!txdb.TxnBegin())
+ return error("SetBestChain() : TxnBegin failed");
+
if (pindexGenesisBlock == NULL && hash == hashGenesisBlock)
{
txdb.WriteHashBestChain(hash);
@@ -1545,7 +1547,10 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew)
printf("SetBestChain() : ReadFromDisk failed\n");
break;
}
- txdb.TxnBegin();
+ if (!txdb.TxnBegin()) {
+ printf("SetBestChain() : TxnBegin 2 failed\n");
+ break;
+ }
// errors now are not fatal, we still did a reorganisation to a new chain in a valid way
if (!block.SetBestChainInner(txdb, pindex))
break;
@@ -1603,7 +1608,8 @@ bool CBlock::AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos)
pindexNew->bnChainWork = (pindexNew->pprev ? pindexNew->pprev->bnChainWork : 0) + pindexNew->GetBlockWork();
CTxDB txdb;
- txdb.TxnBegin();
+ if (!txdb.TxnBegin())
+ return false;
txdb.WriteBlockIndex(CDiskBlockIndex(pindexNew));
if (!txdb.TxnCommit())
return false;