Fix write nil in buffered vectorised writer

This commit is contained in:
世界 2023-03-18 16:30:47 +08:00
parent 2adcd8e205
commit 18cd006d26
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

View file

@ -65,6 +65,11 @@ type BufferedVectorisedWriter struct {
func (w *BufferedVectorisedWriter) WriteVectorised(buffers []*buf.Buffer) error {
defer buf.ReleaseMulti(buffers)
bufferLen := buf.LenMulti(buffers)
if bufferLen == 0 {
return common.Error(w.upstream.Write(nil))
} else if len(buffers) == 1 {
return common.Error(w.upstream.Write(buffers[0].Bytes()))
}
var bufferBytes []byte
if bufferLen > 65535 {
bufferBytes = make([]byte, bufferLen)