Skip to content

Commit

Permalink
fix: allocate stream state if needed in ResetWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed Jan 31, 2023
1 parent 18a70bc commit 6ce80d8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions w.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ func (w *Writer) Reset() {
// ResetWriter resets underlying buffer and sets output writer.
func (w *Writer) ResetWriter(out io.Writer) {
w.Buf = w.Buf[:0]
if w.stream == nil {
w.stream = newStreamState(out)
}
w.stream.Reset(out)
}

Expand Down

0 comments on commit 6ce80d8

Please sign in to comment.