mirror of
https://github.com/nadoo/glider.git
synced 2025-04-22 04:02:07 +08:00
optimize: put the buffer back if err is not nil
This commit is contained in:
parent
91f41c6dfa
commit
37211bc484
@ -92,6 +92,7 @@ func (r *aeadReader) readChunkPool() ([]byte, error) {
|
||||
}
|
||||
chunk := pool.GetBuffer(int(size))
|
||||
if _, err := io.ReadFull(r.Reader, chunk); err != nil {
|
||||
pool.PutBuffer(chunk)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -100,6 +101,7 @@ func (r *aeadReader) readChunkPool() ([]byte, error) {
|
||||
r.count++
|
||||
|
||||
if err != nil {
|
||||
pool.PutBuffer(chunk)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user