From cf1ad300bb32c30d2175f3f074606866d6960f1c Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Tue, 28 Nov 2023 15:45:14 -0500 Subject: [PATCH] utils: close a couple of ReadClosers utils.Tar() and utils.TarWithChroot() both return ReadClosers, but when we called them from utils.TarToFilesystem() and utils.TarChrootToFilesystem() respectively, they were not being closed. [NO NEW TESTS NEEDED] Signed-off-by: Nalin Dahyabhai --- utils/utils.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utils/utils.go b/utils/utils.go index f73672c7a4..08b2fa37a0 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -77,6 +77,7 @@ func TarToFilesystem(source string, tarball *os.File) error { if err != nil { return err } + defer tb.Close() _, err = io.Copy(tarball, tb) if err != nil { return err @@ -98,6 +99,7 @@ func TarChrootToFilesystem(source string, tarball *os.File) error { if err != nil { return err } + defer tb.Close() _, err = io.Copy(tarball, tb) if err != nil { return err