diff options
author | Jeff Garzik <jgarzik@exmulti.com> | 2012-05-14 01:11:11 -0400 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2012-05-18 00:03:32 +0000 |
commit | 738592a002003246849e4b3102aebdab738e976a (patch) | |
tree | f4923bf5b3417bb88a07d3a55fa5c9f2a1f16087 /src | |
parent | c455aec6997ad9164f1083e93bb51095a25180cd (diff) | |
download | bitcoin-738592a002003246849e4b3102aebdab738e976a.tar.xz |
Always check return values of TxnBegin() and TxnCommit()
PARTIAL, since d68dcf7 isn't backported (yet)
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 7 | ||||
-rw-r--r-- | src/rpc.cpp | 6 | ||||
-rw-r--r-- | src/wallet.cpp | 3 |
3 files changed, 11 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp index 0abba822a8..abacbe5e63 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1336,7 +1336,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); @@ -1416,7 +1418,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; diff --git a/src/rpc.cpp b/src/rpc.cpp index 8a02d95c1b..e2ae17e47b 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -723,7 +723,8 @@ Value movecmd(const Array& params, bool fHelp) strComment = params[4].get_str(); CWalletDB walletdb(pwalletMain->strWalletFile); - walletdb.TxnBegin(); + if (!walletdb.TxnBegin()) + throw JSONRPCError(-20, "database error"); int64 nNow = GetAdjustedTime(); @@ -745,7 +746,8 @@ Value movecmd(const Array& params, bool fHelp) credit.strComment = strComment; walletdb.WriteAccountingEntry(credit); - walletdb.TxnCommit(); + if (!walletdb.TxnCommit()) + throw JSONRPCError(-20, "database error"); return true; } diff --git a/src/wallet.cpp b/src/wallet.cpp index b3eb06a3f6..6bf8e582f8 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -165,7 +165,8 @@ bool CWallet::EncryptWallet(const string& strWalletPassphrase) if (fFileBacked) { pwalletdbEncryption = new CWalletDB(strWalletFile); - pwalletdbEncryption->TxnBegin(); + if (!pwalletdbEncryption->TxnBegin()) + return false; pwalletdbEncryption->WriteMasterKey(nMasterKeyMaxID, kMasterKey); } |