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 <thanm@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Than McIntosh <thanm@google.com>
This commit is contained in:
guoguangwu 2024-04-06 06:28:34 +00:00 committed by Gopher Robot
parent 20f052c83c
commit ddc6e165fd

View File

@ -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)