Skip to content

Commit be943c3

Browse files
vxxvvxxvVladimir SokolovskiyShaptic
authored
Fix memory leak in clients/horizonclient/client.go:166 - stream (#5747)
* fix: memory leak in stream operations * chore: change CHANGELOG.md --------- Co-authored-by: Vladimir Sokolovskiy <vladimir.sokolovskiy@armenotech.com> Co-authored-by: George <Shaptic@users.noreply.github.com>
1 parent 28e65f7 commit be943c3

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

clients/horizonclient/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ file. This project adheres to [Semantic Versioning](http://semver.org/).
88
## [v11.0.0](https://github.com/stellar/go/releases/tag/horizonclient-v11.0.0) - 2023-03-29
99

1010
* Type of `AccountSequence` field in `protocols/horizon.Account` was changed to `int64`.
11+
* Fixed memory leak in `stream` function in `client.go` due to incorrect `resp.Body.Close` handling.
1112

1213
## [v10.0.0](https://github.com/stellar/go/releases/tag/horizonclient-v10.0.0) - 2022-04-18
1314

clients/horizonclient/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@ func (c *Client) stream(
158158
if err != nil {
159159
return errors.Wrap(err, "error sending HTTP request")
160160
}
161+
defer resp.Body.Close()
161162

162163
// Expected statusCode are 200-299
163164
if !(resp.StatusCode >= 200 && resp.StatusCode < 300) {
164165
return fmt.Errorf("got bad HTTP status code %d", resp.StatusCode)
165166
}
166-
defer resp.Body.Close()
167167

168168
reader := bufio.NewReader(resp.Body)
169169

0 commit comments

Comments
 (0)