aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCasey Rodarmor <casey@rodarmor.com>2015-07-28 14:01:00 -0400
committerCasey Rodarmor <casey@rodarmor.com>2015-07-28 14:01:00 -0400
commit17ac0f402559f57733fb5da6dafb72cf0f50795f (patch)
tree651362fdc0600ed26363287237be17d42acadeb2
parent1369d699b6221818dc9ca72eb6c0cea30eeee914 (diff)
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 9ad57d5c6f..e389d51a73 100644
--- a/src/bitcoin-tx.cpp
+++ b/src/bitcoin-tx.cpp
@@ -143,13 +143,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);
}