diff --git a/clients/horizonclient/CHANGELOG.md b/clients/horizonclient/CHANGELOG.md index bcd3ef331d..33df7b1245 100644 --- a/clients/horizonclient/CHANGELOG.md +++ b/clients/horizonclient/CHANGELOG.md @@ -8,6 +8,7 @@ file. This project adheres to [Semantic Versioning](http://semver.org/). ## [v11.0.0](https://github.com/stellar/go/releases/tag/horizonclient-v11.0.0) - 2023-03-29 * Type of `AccountSequence` field in `protocols/horizon.Account` was changed to `int64`. +* Fixed memory leak in `stream` function in `client.go` due to incorrect `resp.Body.Close` handling. ## [v10.0.0](https://github.com/stellar/go/releases/tag/horizonclient-v10.0.0) - 2022-04-18 diff --git a/clients/horizonclient/client.go b/clients/horizonclient/client.go index 0c580de771..18abca491c 100644 --- a/clients/horizonclient/client.go +++ b/clients/horizonclient/client.go @@ -158,12 +158,12 @@ func (c *Client) stream( if err != nil { return errors.Wrap(err, "error sending HTTP request") } + defer resp.Body.Close() // Expected statusCode are 200-299 if !(resp.StatusCode >= 200 && resp.StatusCode < 300) { return fmt.Errorf("got bad HTTP status code %d", resp.StatusCode) } - defer resp.Body.Close() reader := bufio.NewReader(resp.Body)