From 1d055eb4a50bce8d1a05a04cf63575aa04c5b0aa Mon Sep 17 00:00:00 2001 From: razzle Date: Wed, 15 Mar 2023 13:50:42 -0500 Subject: [PATCH] defer closing file (#1668) Signed-off-by: razzle --- syft/source/source.go | 1 + 1 file changed, 1 insertion(+) diff --git a/syft/source/source.go b/syft/source/source.go index 76b5470638e..b0cb948e0ff 100644 --- a/syft/source/source.go +++ b/syft/source/source.go @@ -385,6 +385,7 @@ func (s *Source) SetID() { case FileScheme: // attempt to use the digest of the contents of the file as the ID file, err := os.Open(s.Metadata.Path) + defer file.Close() if err != nil { d = digest.FromString(s.Metadata.Path).String() break