optimize: put the buffer back if err is not nil

This commit is contained in:
mzz2017 2021-12-23 19:07:44 +08:00
parent 91f41c6dfa
commit 37211bc484
2 changed files with 2 additions and 0 deletions

View File

@ -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
}

BIN
speedtest Executable file

Binary file not shown.