Browse Source

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.
0.13
Casey Rodarmor 10 years ago
parent
commit
17ac0f4025
  1. 7
      src/bitcoin-tx.cpp

7
src/bitcoin-tx.cpp

@ -143,13 +143,14 @@ static void RegisterLoad(const string& strInput) @@ -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);
}

Loading…
Cancel
Save