From f458529c74944c2d08d0587b775de86d1706cb1f Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Tue, 14 Jul 2020 00:20:58 +0200 Subject: [PATCH] fix memory leak? --- peer/http3/client.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/peer/http3/client.go b/peer/http3/client.go index 85bd57d..4aa5381 100644 --- a/peer/http3/client.go +++ b/peer/http3/client.go @@ -62,6 +62,7 @@ func (c *Client) HasBlob(hash string) (bool, error) { if err != nil { return false, errors.Err(err) } + defer resp.Body.Close() if resp.StatusCode == http.StatusOK { return true, nil } @@ -77,6 +78,7 @@ func (c *Client) GetBlob(hash string) (stream.Blob, error) { if err != nil { return nil, errors.Err(err) } + defer resp.Body.Close() if resp.StatusCode == http.StatusNotFound { fmt.Printf("%s blob not found %d\n", hash, resp.StatusCode) return nil, errors.Err(store.ErrBlobNotFound)