Buffers are not returned to the pool in the case of errors.
Per https://golang.org/pkg/bytes/#Buffer.Bytes, the slice returned
from bytes.Buffer.Bytes() is only valid until the next modification
of the buffer, so it must be copied before the buffer is returned to the pool.
Two problems are fixed:
Running
go test -race
detected the following:Signed-off-by: Ed Bardsley ewb@uber.com