From 3b54c0fc00fa8997717827f93cba49a1627f97cb Mon Sep 17 00:00:00 2001 From: xtaci Date: Thu, 19 Dec 2019 16:18:34 +0800 Subject: [PATCH] fix a possible race condition --- stream.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stream.go b/stream.go index d60e3e3..c8a518a 100644 --- a/stream.go +++ b/stream.go @@ -103,8 +103,8 @@ func (s *Stream) WriteTo(w io.Writer) (n int64, err error) { if buf != nil { nw, ew := w.Write(buf) - defaultAllocator.Put(buf) s.sess.returnTokens(len(buf)) + defaultAllocator.Put(buf) if nw > 0 { n += int64(nw) }