Skip to content

Commit

Permalink
Close file if permission modification fails
Browse files Browse the repository at this point in the history
Signed-off-by: Shiming Zhang <wzshiming@foxmail.com>
  • Loading branch information
wzshiming committed Nov 15, 2021
1 parent 5b09dc5 commit db124c5
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions archive/tar_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func openFile(name string, flag int, perm os.FileMode) (*os.File, error) {
}
// Call chmod to avoid permission mask
if err := os.Chmod(name, perm); err != nil {
f.Close()
return nil, err
}
return f, err
Expand Down

0 comments on commit db124c5

Please sign in to comment.