Skip to content

Commit 7cbed7f

Browse files
committed
Merge pull request #6488
17ac0f4 Avoid leaking file descriptors in RegisterLoad (Casey Rodarmor)
2 parents eddaba7 + 17ac0f4 commit 7cbed7f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/bitcoin-tx.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,14 @@ static void RegisterLoad(const string& strInput)
143143
valStr.insert(valStr.size(), buf, bread);
144144
}
145145

146-
if (ferror(f)) {
146+
int error = ferror(f);
147+
fclose(f);
148+
149+
if (error) {
147150
string strErr = "Error reading file " + filename;
148151
throw runtime_error(strErr);
149152
}
150153

151-
fclose(f);
152-
153154
// evaluate as JSON buffer register
154155
RegisterSetJson(key, valStr);
155156
}

0 commit comments

Comments
 (0)