From 25fad82a36deb12e43a8d1eff4c68ef57f978ac0 Mon Sep 17 00:00:00 2001 From: Just a baka <416302+justabaka@users.noreply.github.com> Date: Fri, 28 Feb 2020 20:12:34 +0300 Subject: [PATCH] Fix Null Pointer Dereference on HTTP Client errors Don't try to access resp if there was a problem before. --- client.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client.go b/client.go index e8fa3c3..7d7f72c 100644 --- a/client.go +++ b/client.go @@ -110,6 +110,9 @@ func executeRequest(client *Client, req *http.Request) (res *http.Response, err httpc.Transport = client.transport } resp, err := httpc.Do(req) + if err != nil { + return nil, err + } if resp.StatusCode == 401 { return nil, errors.New("Error: API responded with a 401 Unauthorized")