Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/hex: Dumper can produce incorrect output if Close is called multiple times #23574

Closed
ghost opened this issue Jan 26, 2018 · 2 comments
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@ghost
Copy link

ghost commented Jan 26, 2018

What version of Go are you using (go version)?

go1.9.2

What did you do?

https://play.golang.org/p/mxGWipaSUGN

package main

import (
	"encoding/hex"
	"os"
)

func main() {
	d := hex.Dumper(os.Stdout)
	d.Write([]byte(`gopher`))
	d.Close()
	d.Close()
}

What did you expect to see?

00000000  67 6f 70 68 65 72                                 |gopher|

What did you see instead?

00000000  67 6f 70 68 65 72                                 |gopher|
gopher|
|

Calling Close twice is obviously a mistake, but it seems we might as well do something more intelligent than what is currently happening. I doubt anyone is relying the current behaviour.

Mailing CL.

@gopherbot
Copy link

Change https://golang.org/cl/90275 mentions this issue: encoding/hex: fix potential incorrect Dumper output when Close is called multiple times

@bradfitz bradfitz added the NeedsFix The path to resolution is known, but the work has not been done. label Jan 26, 2018
@bradfitz bradfitz added this to the Go1.11 milestone Jan 26, 2018
@gopherbot
Copy link

Change https://golang.org/cl/107596 mentions this issue: encoding/hex: fix Dumper not always closing on Close call

gopherbot pushed a commit that referenced this issue Apr 17, 2018
Updates #23574

Change-Id: I1b87390679e0817a2f6e4e5938994ea32df87bd7
Reviewed-on: https://go-review.googlesource.com/107596
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@golang golang locked and limited conversation to collaborators Apr 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

2 participants