aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorPhilip Kaufmann <phil.kaufmann@t-online.de>2014-09-25 08:53:43 +0200
committerPhilip Kaufmann <phil.kaufmann@t-online.de>2014-10-02 10:46:31 +0200
commitc9fb27da0a72135417956dca8dafa959ebb67c10 (patch)
tree7676f91bda9f87762ff5cdd2cbee18eba50dd854 /src/main.cpp
parent00eef5d6e9b08b173492599ec41c7feb445e2139 (diff)
downloadbitcoin-c9fb27da0a72135417956dca8dafa959ebb67c10.tar.xz
CBufferedFile: convert into a non-refcounted RAII wrapper
- it now takes over the passed file descriptor and closes it in the destructor - this fixes a leak in LoadExternalBlockFile(), where an exception could cause the file to not getting closed - disallow copies (like recently added for CAutoFile) - make nType and nVersion private
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index a3e36ff872..0333738887 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -3084,6 +3084,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
int nLoaded = 0;
try {
+ // This takes over fileIn and calls fclose() on it in the CBufferedFile destructor
CBufferedFile blkdat(fileIn, 2*MAX_BLOCK_SIZE, MAX_BLOCK_SIZE+8, SER_DISK, CLIENT_VERSION);
uint64_t nStartByte = 0;
if (dbp) {
@@ -3140,7 +3141,6 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
LogPrintf("%s : Deserialize or I/O error - %s", __func__, e.what());
}
}
- fclose(fileIn);
} catch(std::runtime_error &e) {
AbortNode(_("Error: system error: ") + e.what());
}