From 9db1dd074df62d18f6902f06c93c72da0a3ffd16 Mon Sep 17 00:00:00 2001 From: Tim Cooper Date: Tue, 17 Apr 2018 16:55:42 -0300 Subject: encoding/hex: fix Dumper not always closing on Close call Updates #23574 Change-Id: I1b87390679e0817a2f6e4e5938994ea32df87bd7 Reviewed-on: https://go-review.googlesource.com/107596 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/encoding/hex/hex.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/encoding/hex/hex.go') diff --git a/src/encoding/hex/hex.go b/src/encoding/hex/hex.go index edc53954a1..4cb26b6673 100644 --- a/src/encoding/hex/hex.go +++ b/src/encoding/hex/hex.go @@ -282,10 +282,13 @@ func (h *dumper) Write(data []byte) (n int, err error) { func (h *dumper) Close() (err error) { // See the comments in Write() for the details of this format. - if h.used == 0 || h.closed { + if h.closed { return } h.closed = true + if h.used == 0 { + return + } h.buf[0] = ' ' h.buf[1] = ' ' h.buf[2] = ' ' -- cgit v1.3-5-g9baa