aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCasey Rodarmor <casey@rodarmor.com>2015-07-28 14:01:00 -0400
committerLuke Dashjr <luke-jr+git@utopios.org>2015-09-22 00:43:11 +0000
commitf6355e69183f20c3d1fd1b9adbb4f3a00ad680ac (patch)
treeb6db6954b06c61f70aeb2af2a4b77a2a2da6c73c
parent60457d3c2f3f38d4cc3e524a5d4030bf4034b7aa (diff)
downloadbitcoin-f6355e69183f20c3d1fd1b9adbb4f3a00ad680ac.tar.xz
Avoid leaking file descriptors in RegisterLoad
This is pretty trivial, but if there's an error here we'll leak a file descriptor. Changed it to always close the file.
-rw-r--r--src/bitcoin-tx.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp
index c82d4f93a8..40b4a38e41 100644
--- a/src/bitcoin-tx.cpp
+++ b/src/bitcoin-tx.cpp
@@ -142,13 +142,14 @@ static void RegisterLoad(const string& strInput)
valStr.insert(valStr.size(), buf, bread);
}
- if (ferror(f)) {
+ int error = ferror(f);
+ fclose(f);
+
+ if (error) {
string strErr = "Error reading file " + filename;
throw runtime_error(strErr);
}
- fclose(f);
-
// evaluate as JSON buffer register
RegisterSetJson(key, valStr);
}