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-21 05:21:29 +0000
commit04507de3b7af34c2fcb1b90f405b2e8a9c35ebe9 (patch)
tree6a808c15d4604bf28c5d470e1b1a08f25a774f02
parent8b59079b8d7eda6f44988649d9c716fec3aad397 (diff)
downloadbitcoin-04507de3b7af34c2fcb1b90f405b2e8a9c35ebe9.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 c1be1229d3..3aa2211f97 100644
--- a/src/bitcoin-tx.cpp
+++ b/src/bitcoin-tx.cpp
@@ -149,13 +149,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);
}