Explorar o código

always allocate buffer in Write

Darien Raymond %!s(int64=8) %!d(string=hai) anos
pai
achega
23b768576e
Modificáronse 1 ficheiros con 4 adicións e 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)