Skip to content

Commit

Permalink
fix: close file when failed to open gzip
Browse files Browse the repository at this point in the history
Signed-off-by: guoguangwu <[email protected]>
  • Loading branch information
testwill committed Jul 15, 2024
1 parent 4308a0a commit 9b41aca
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions pkg/fanal/image/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func fileOpener(fileName string) func() (io.ReadCloser, error) {
if utils.IsGzip(br) {
r, err = gzip.NewReader(br)
if err != nil {
f.Close()

Check failure on line 38 in pkg/fanal/image/docker.go

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest-m)

G104: Errors unhandled. (gosec)
return nil, xerrors.Errorf("failed to open gzip: %w", err)
}
}
Expand Down

0 comments on commit 9b41aca

Please sign in to comment.