From e27484cd43e21599ba6e798ab74a703ad290ae7c Mon Sep 17 00:00:00 2001 From: guoguangwu Date: Sat, 6 Apr 2024 14:24:07 +0800 Subject: [PATCH] cmd/link: close the file opened in the captureHostObj function Signed-off-by: guoguangwu --- src/cmd/link/internal/ld/lib.go | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index 35b9ca01d2..823c395273 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -2848,6 +2848,7 @@ func captureHostObj(h *Hostobj) { if err != nil { log.Fatalf("capturing host obj: open failed on %s: %v", h.pn, err) } + defer inf.Close() res := make([]byte, h.length) if n, err := inf.ReadAt(res, h.off); err != nil || n != int(h.length) { log.Fatalf("capturing host obj: readat failed on %s: %v", h.pn, err)