diff --git a/cmd/gsa/entry.go b/cmd/gsa/entry.go index a548e8f6de..67bb433ab3 100644 --- a/cmd/gsa/entry.go +++ b/cmd/gsa/entry.go @@ -66,6 +66,11 @@ func entry() error { return err } + err = reader.Close() + if err != nil { + return err + } + if Options.Tui { w, h, err := term.GetSize(os.Stdout.Fd()) if err != nil { diff --git a/internal/diff/load.go b/internal/diff/load.go index 38937fefad..627eea04f0 100644 --- a/internal/diff/load.go +++ b/internal/diff/load.go @@ -71,6 +71,12 @@ func autoLoadFile(name string, options internal.Options) (*commonResult, error) if err != nil { return nil, err } + defer func(reader *mmap.ReaderAt) { + err = reader.Close() + if err != nil { + slog.Warn("failed to close file", "error", err) + } + }(reader) r := new(commonResult) if utils.DetectJSON(reader) { diff --git a/internal/test/test.go b/internal/test/test.go index f4b374fe4b..805385fd45 100644 --- a/internal/test/test.go +++ b/internal/test/test.go @@ -92,6 +92,9 @@ func GetTestResult(t *testing.T) *result.Result { f, err := mmap.Open(path) require.NoError(t, err) + defer func(f *mmap.ReaderAt) { + require.NoError(t, f.Close()) + }(f) r, err := internal.Analyze(path, f, uint64(f.Len()), internal.Options{ SkipDwarf: false,