Skip to content

Commit

Permalink
πŸ› fix: fuck invalid byte array
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavin Guan committed Nov 5, 2019
1 parent b059226 commit af0f972
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions core/byteArrPool.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ func (pool *byteArrPool) Get(args ...int) []byte {
}

func (pool *byteArrPool) Put(arr []byte) {
arr = arr[:cap(arr)]
pool.Pool.Put(arr)
capVal := cap(arr)
if capVal >= pool.sizeLimit {
arr = arr[:capVal]
pool.Pool.Put(arr)
}
}

func NewByteArrPool(sizeLimit int) *byteArrPool {
Expand Down

0 comments on commit af0f972

Please sign in to comment.