Merge pull request #6246 from wzshiming/fix/close-file-with-modify-perm

Close file if permission modification fails
This commit is contained in:
Derek McGowan 2021-11-15 15:45:35 -08:00 committed by GitHub
commit 77e76d7a52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -85,6 +85,7 @@ func openFile(name string, flag int, perm os.FileMode) (*os.File, error) {
} }
// Call chmod to avoid permission mask // Call chmod to avoid permission mask
if err := os.Chmod(name, perm); err != nil { if err := os.Chmod(name, perm); err != nil {
f.Close()
return nil, err return nil, err
} }
return f, err return f, err