diff --git a/pkg/action/diff.go b/pkg/action/diff.go index 6a8031ff1..ddc337e61 100644 --- a/pkg/action/diff.go +++ b/pkg/action/diff.go @@ -251,14 +251,13 @@ func Diff(ctx context.Context, c malcontent.Config, _ *clog.Logger) (*malcontent if err != nil { return nil, err } + defer srcFile.Close() st, err := srcFile.Stat() if err != nil { return nil, err } - defer srcFile.Close() - // create a buffer sized to the minimum of the file's size or the default ReadBuffer // only do so if we actually need to retrieve the file's contents buf := readPool.Get(min(st.Size(), file.ReadBuffer)) //nolint:nilaway // the buffer pool is created above