Skip to content

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

@ghost

Description

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions