When fclose() fails, the file handle was not being closed before returning false. This could lead to a resource leak. Fix by ensuring the file handle is always closed, even when fclose() returns an error.
Fix/readwritefile fclose #35063
pull flawlesscode254 wants to merge 5 commits into bitcoin:master from flawlesscode254:fix/readwritefile-fclose changing 5 files +8 −3-
flawlesscode254 commented at 4:18 AM on April 12, 2026: none
-
30f6c59244
util/moneystr: fix potential out-of-bounds access in FormatMoney
The loop in FormatMoney accesses str[i-2] without first checking that i >= 2. If str.size() < 3, this could read out of bounds. Fix by adding explicit bounds check i >= 2 to the loop condition.
-
b0ccce1126
validation: fix potential integer underflow in reverse loop
When block.vtx is empty, block.vtx.size() - 1 causes underflow since size() returns size_t (unsigned). Cast to int to prevent this.
-
5dfdb6d04b
wallet/rpc/spend: fix potential division by zero
Check if addresses_without_amount is empty before performing division to prevent division by zero when no addresses are specified.
-
9b34475a5c
net_processing: fix potential integer underflow in reverse loop
When headers vector is empty, headers.size() - 1 causes underflow since size() returns size_t (unsigned). Cast to int to prevent this.
-
bbf0f41b0d
util/readwritefile: fix file handle leak on fclose failure
When fclose() fails, the file handle was not being closed before returning false. This could lead to a resource leak.
-
DrahtBot commented at 4:18 AM on April 12, 2026: contributor
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--021abf342d371248e50ceaed478a90ca-->
Reviews
See the guideline for information on the review process. A summary of reviews will appear here.
<!--5faf32d7da4f0f540f40219e4f7537a3-->
-
maflcko commented at 6:23 AM on April 13, 2026: member
ai slop
- maflcko closed this on Apr 13, 2026
Contributors