From e6b5872bc8cfc9677b0fb7edc15e1f57cea832f8 Mon Sep 17 00:00:00 2001 From: mikey strauss Date: Thu, 17 Feb 2022 20:10:08 +0200 Subject: [PATCH] Base64 encoder closing (#822) Signed-off-by: houdini91 --- syft/file/contents_cataloger.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/syft/file/contents_cataloger.go b/syft/file/contents_cataloger.go index 93ede0a96..8ef0a6615 100644 --- a/syft/file/contents_cataloger.go +++ b/syft/file/contents_cataloger.go @@ -64,9 +64,11 @@ func (i *ContentsCataloger) catalogLocation(resolver source.FileResolver, locati defer internal.CloseAndLogError(contentReader, location.VirtualPath) buf := &bytes.Buffer{} - if _, err = io.Copy(base64.NewEncoder(base64.StdEncoding, buf), contentReader); err != nil { + encoder := base64.NewEncoder(base64.StdEncoding, buf) + if _, err = io.Copy(encoder, contentReader); err != nil { return "", internal.ErrPath{Path: location.RealPath, Err: err} } + encoder.Close() return buf.String(), nil }