From 94e97ace7e0bd07b7594d873284c4679a94ef6eb Mon Sep 17 00:00:00 2001 From: Lucas Martins Date: Thu, 27 May 2021 14:13:18 -0300 Subject: [PATCH] Fix memory leak when using http auth --- app/helpers.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/helpers.go b/app/helpers.go index 72cbb9b..eb44a83 100644 --- a/app/helpers.go +++ b/app/helpers.go @@ -11,6 +11,8 @@ import ( "bytes" "context" "encoding/json" + "io" + "io/ioutil" "net/http" "strings" "time" @@ -126,6 +128,12 @@ func httpAuthorize(app *App, userID string, topics []string) (bool, []string, er } response, err := client.Do(request) + // discard response body + if response != nil && response.Body != nil { + _, _ = io.Copy(ioutil.Discard, response.Body) + _ = response.Body.Close() + } + if err != nil { return false, nil, err }