Explorar el Código

always allocate buffer in Write

Darien Raymond hace 8 años
padre
commit
23b768576e
Se han modificado 1 ficheros con 4 adiciones y 0 borrados
  1. 4 0
      common/buf/writer.go

+ 4 - 0
common/buf/writer.go

@@ -60,6 +60,10 @@ func (w *BufferedWriter) Write(b []byte) (int, error) {
 		return w.legacyWriter.Write(b)
 	}
 
+	if w.buffer == nil {
+		w.buffer = New()
+	}
+
 	totalBytes := 0
 	for len(b) > 0 {
 		nBytes, err := w.buffer.Write(b)