From fe860b834e0c0ba0fd0073c11a4806720f52d628 Mon Sep 17 00:00:00 2001 From: Steve Beattie Date: Thu, 5 Feb 2026 16:11:21 -0800 Subject: [PATCH] fix: one more deferred close adjustment Minor fix that was unlikely to actually trigger a leak (fstat(2) would need to fail, which seems pretty unlikely). Signed-off-by: Steve Beattie --- pkg/action/diff.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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