[Pkg-bitcoin-commits] [bitcoin] 01/126: [wallet] Close DB on error.

Jonas Smedegaard dr at jones.dk
Mon Nov 13 20:00:25 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/0.15.1_dfsg-1
in repository bitcoin.

commit 9e8aae31c103e1d76365c34ce1fe1dd68e93912b
Author: Karl-Johan Alm <karljohan-alm at garage.co.jp>
Date:   Wed Aug 9 17:24:15 2017 +0900

    [wallet] Close DB on error.
    
    Github-Pull: #11017
    Rebased-From: 03bc719a85cb4928cb4b43d0bc4142f72cb01b23
---
 src/wallet/db.cpp | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp
index b12d46e..d2fe486 100644
--- a/src/wallet/db.cpp
+++ b/src/wallet/db.cpp
@@ -101,8 +101,10 @@ bool CDBEnv::Open(const fs::path& pathIn)
                              DB_RECOVER |
                              nEnvFlags,
                          S_IRUSR | S_IWUSR);
-    if (ret != 0)
+    if (ret != 0) {
+        dbenv->close(0);
         return error("CDBEnv::Open: Error %d opening database environment: %s\n", ret, DbEnv::strerror(ret));
+    }
 
     fDbEnvInit = true;
     fMockDb = false;
@@ -196,9 +198,9 @@ bool CDB::Recover(const std::string& filename, void *callbackDataIn, bool (*reco
                             DB_BTREE,           // Database type
                             DB_CREATE,          // Flags
                             0);
-    if (ret > 0)
-    {
+    if (ret > 0) {
         LogPrintf("Cannot create database file %s\n", filename);
+        pdbCopy->close(0);
         return false;
     }
 
@@ -536,8 +538,10 @@ bool CDB::Rewrite(CWalletDBWrapper& dbw, const char* pszSkip)
                         env->CloseDb(strFile);
                         if (pdbCopy->close(0))
                             fSuccess = false;
-                        delete pdbCopy;
+                    } else {
+                        pdbCopy->close(0);
                     }
+                    delete pdbCopy;
                 }
                 if (fSuccess) {
                     Db dbA(env->dbenv, 0);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-bitcoin/bitcoin.git



More information about the Pkg-bitcoin-commits mailing list