From: guoguangwu Date: Sat, 6 Apr 2024 06:28:34 +0000 (+0000) Subject: cmd/link: close the file opened in the captureHostObj function X-Git-Tag: go1.23rc1~674 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ddc6e165fd84cf7d46f743dabe925835f16a73ee;p=gostls13.git cmd/link: close the file opened in the captureHostObj function Change-Id: I940c63c3040035e507428798d50060cfd0d04e16 GitHub-Last-Rev: e27484cd43e21599ba6e798ab74a703ad290ae7c GitHub-Pull-Request: golang/go#66706 Reviewed-on: https://go-review.googlesource.com/c/go/+/577055 Reviewed-by: Than McIntosh Auto-Submit: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI Reviewed-by: Cherry Mui Auto-Submit: Than McIntosh --- 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)