]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/pprof: close resp body after the profile.Parse is called
authorguoguangwu <guoguangwug@gmail.com>
Mon, 15 Apr 2024 02:11:58 +0000 (02:11 +0000)
committerGopher Robot <gobot@golang.org>
Mon, 15 Apr 2024 16:20:39 +0000 (16:20 +0000)
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 <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/pprof/pprof.go

index bc1a4cf9f75a186916bf9a76a9460c03201ed2dd..d4db9df285171e4855ca26eb112ec7f0f1c0f3dc 100644 (file)
@@ -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)