From db124c560ccadaa5ea5ce6e478cc141a764d2589 Mon Sep 17 00:00:00 2001 From: Shiming Zhang Date: Mon, 15 Nov 2021 16:53:48 +0800 Subject: [PATCH] Close file if permission modification fails Signed-off-by: Shiming Zhang --- archive/tar_unix.go | 1 + 1 file changed, 1 insertion(+) diff --git a/archive/tar_unix.go b/archive/tar_unix.go index c4f628784..c5ddf596f 100644 --- a/archive/tar_unix.go +++ b/archive/tar_unix.go @@ -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