From ddb3d7e34aba53a53bca4d12dadec9a4fd583595 Mon Sep 17 00:00:00 2001 From: panoskoug <77088026+panoskoug@users.noreply.github.com> Date: Tue, 3 Aug 2021 22:55:46 -0700 Subject: [PATCH] fixes a leak on every REST request per Do documentation: "If the returned error is nil, the Response will contain a non-nil Body which the user is expected to close." --- go/rtl/auth.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/go/rtl/auth.go b/go/rtl/auth.go index 14a4a13fc..836d4aca5 100644 --- a/go/rtl/auth.go +++ b/go/rtl/auth.go @@ -132,6 +132,8 @@ func (s *AuthSession) Do(result interface{}, method, ver, path string, reqPars m if err != nil { return err } + defer res.Body.Close() + if res.StatusCode < 200 || res.StatusCode > 226 { return fmt.Errorf("response error: %s", res.Status) @@ -209,4 +211,4 @@ func setQuery(u *url.URL, pars map[string]interface{}) { } } u.RawQuery = q.Encode() -} \ No newline at end of file +}