Skip to content

Commit 37740a3

Browse files
authored
Merge pull request #4819 from fedebram/fix-commonlock-nil-pointer
fix: nil pointer panic in commonLock defer
2 parents 1f47197 + b879c1e commit 37740a3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/internal/filesystem/lock.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ func ReadOnlyLock(path string) (file *os.File, err error) {
5151
func commonlock(path string, mode lockType) (file *os.File, err error) {
5252
defer func() {
5353
if err != nil {
54-
err = errors.Join(ErrLockFail, err, file.Close())
54+
err = errors.Join(ErrLockFail, err)
55+
if file != nil {
56+
err = errors.Join(err, file.Close())
57+
}
5558
}
5659
}()
5760

0 commit comments

Comments
 (0)