From: guoguangwu Date: Mon, 15 Apr 2024 02:11:58 +0000 (+0000) Subject: cmd/pprof: close resp body after the profile.Parse is called X-Git-Tag: go1.23rc1~626 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8e987fadb57fa1fc98975ca2fcb3a4751f7f55ff;p=gostls13.git cmd/pprof: close resp body after the profile.Parse is called Change-Id: I5bccef3c46072e388bfe9985e70745853f673a42 GitHub-Last-Rev: adee7b9f7fa21c3ee5561b8233bbfe94168e45ed GitHub-Pull-Request: golang/go#66829 Reviewed-on: https://go-review.googlesource.com/c/go/+/578875 Reviewed-by: Ian Lance Taylor Reviewed-by: Cherry Mui Auto-Submit: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI --- diff --git a/src/cmd/pprof/pprof.go b/src/cmd/pprof/pprof.go index bc1a4cf9f7..d4db9df285 100644 --- a/src/cmd/pprof/pprof.go +++ b/src/cmd/pprof/pprof.go @@ -84,8 +84,8 @@ func getProfile(source string, timeout time.Duration) (*profile.Profile, error) if err != nil { return nil, err } + defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - defer resp.Body.Close() return nil, statusCodeError(resp) } return profile.Parse(resp.Body)