Skip to content
This repository has been archived by the owner on Jun 5, 2021. It is now read-only.

Commit

Permalink
Fix buffer grow for n < length
Browse files Browse the repository at this point in the history
Forbid buffer length decrease.
  • Loading branch information
ernado committed Jul 16, 2019
1 parent 76358cb commit a24dfdb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ func (m *Message) Reset() {

// grow ensures that internal buffer has n length.
func (m *Message) grow(n int) {
if len(m.Raw) >= n {
return
}
if cap(m.Raw) >= n {
m.Raw = m.Raw[:n]
return
Expand Down

0 comments on commit a24dfdb

Please sign in to comment.