Skip to content

Commit

Permalink
fix panic during quota sync (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
theganyo authored Jun 7, 2023
1 parent c9a3d3e commit 777c318
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion analytics/legacy_analytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ func (oa *legacyAnalytics) SendRecords(authContext *auth.Context, records []Reco
}
defer resp.Body.Close()

buf := bytes.NewBuffer(make([]byte, 0, resp.ContentLength))
bufLen := resp.ContentLength
if bufLen < bytes.MinRead {
bufLen = bytes.MinRead
}
buf := bytes.NewBuffer(make([]byte, 0, bufLen))
_, err = buf.ReadFrom(resp.Body)
if err != nil {
return err
Expand Down
6 changes: 5 additions & 1 deletion quota/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ func (b *bucket) sync() error {
}
defer resp.Body.Close()

buf := bytes.NewBuffer(make([]byte, 0, resp.ContentLength))
bufLen := resp.ContentLength
if bufLen < bytes.MinRead {
bufLen = bytes.MinRead
}
buf := bytes.NewBuffer(make([]byte, 0, bufLen))
if _, err = buf.ReadFrom(resp.Body); err != nil {
return errors.Wrap(err, "read body")
}
Expand Down

0 comments on commit 777c318

Please sign in to comment.