Skip to content

Commit

Permalink
fmt: clear width and precision when recovering formatting object from…
Browse files Browse the repository at this point in the history
… the pool

Probably a day 1 oversight, and almost always inconsequential, but
there is evidence of occasional trouble. There is no reason not to
clear them.

I tried and failed to write a test to catch this, but the change should
be harmless and is all but certain to fix the problem.

Fixes golang#61913

Change-Id: I0f7bbb4ab2780d8999d3ff7a35255dc07fb5c7e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/556215
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
  • Loading branch information
robpike authored and ezz-no committed Feb 17, 2024
1 parent fc0f506 commit ee0072b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/fmt/format.go
Expand Up @@ -53,6 +53,8 @@ type fmt struct {

func (f *fmt) clearflags() {
f.fmtFlags = fmtFlags{}
f.wid = 0
f.prec = 0
}

func (f *fmt) init(buf *buffer) {
Expand Down

0 comments on commit ee0072b

Please sign in to comment.