Skip to content

Commit

Permalink
Base64 encoder closing (#822)
Browse files Browse the repository at this point in the history
Signed-off-by: houdini91 <[email protected]>
  • Loading branch information
houdini91 authored Feb 17, 2022
1 parent 641c44f commit e6b5872
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion syft/file/contents_cataloger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit e6b5872

Please sign in to comment.