Conversation
Signed-off-by: Johannes Großmann <grossmann.johannes@t-online.de>
Benehiko
approved these changes
Mar 12, 2026
There was a problem hiding this comment.
Review Summary
Assessment: 🟢 APPROVE
The fix correctly addresses the variable shadowing issue described in the PR. By splitting the short variable declaration (:=) into a separate assignment (=) at line 92, the code now properly reuses the outer err variable. This allows the defer function to correctly close the file lock on error paths.
Analysis:
- ✅ The variable shadowing bug is fixed correctly
- ✅ The defer function will now trigger as intended when errors occur
- ✅ No new bugs introduced by the changes
Note: During review, a potential file handle leak was identified at line 89 (where a second openFile call could replace the first file handle without closing it). However, this issue exists in the unchanged surrounding code, not in the lines modified by this PR, so it's outside the scope of this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a very subtle leak of not closing the file lock correctly in certain circumstances.
At the beginning of the function, we have:
This code relies on re-using the same
errvariable. And we missed that / created a new one that would shadow it on one code path.