fix: Pool panic when putting small buffer

This commit is contained in:
H1JK 2023-12-01 23:13:14 +08:00
parent 7efd692bbc
commit 3b57a923fd

View File

@ -96,6 +96,9 @@ func (alloc *Allocator) Put(buf []byte) error {
if cap(buf) != 1<<bits {
return errors.New("allocator Put() incorrect buffer size")
}
if cap(buf) < 1<<6 {
return nil
}
bits -= 6
buf = buf[:cap(buf)]