Skip to content

Commit e375d03

Browse files
committed
replace buffer when borrowing encoding to avoid race condition
1 parent 4fc4320 commit e375d03

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

encode_pool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func NewEncoder(w io.Writer) *Encoder {
3535
func BorrowEncoder(w io.Writer) *Encoder {
3636
enc := encPool.Get().(*Encoder)
3737
enc.w = w
38-
enc.buf = enc.buf[:0]
38+
enc.buf = make([]byte, 0, 512)
3939
enc.isPooled = 0
4040
enc.err = nil
4141
return enc

0 commit comments

Comments
 (0)