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/xml: panics when trying to unmarshal a named attribute into a non-byte slice #11723

Closed
ainar-g opened this issue Jul 15, 2015 · 4 comments
Labels
FrozenDueToAge Suggested Issues that may be good for new contributors looking for work to do.
Milestone

Comments

@ainar-g
Copy link
Contributor

ainar-g commented Jul 15, 2015

Go versions:

  • go version devel +2e4b659 Wed Jul 15 06:04:51 2015 +0000 linux/amd64
  • go version go1.4.2 linux/amd64

Code: http://play.golang.org/p/ZxYJ0EFsfv.

Expected: an error, something like unsupported type: []string.

Got: panic: reflect.Value.SetBytes of non-byte slice. Same with []int or any other non-byte slice.

May be related to #6341.

@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Jul 15, 2015
@ianlancetaylor ianlancetaylor added the Suggested Issues that may be good for new contributors looking for work to do. label Jul 15, 2015
@ianlancetaylor
Copy link
Contributor

I think we just need to change copyValue in encoding/xml/read.go to check the element type of the slice before calling SetBytes.

@andrestc
Copy link
Contributor

Instead of panicking, running the code on http://play.golang.org/p/ZxYJ0EFsfv returns:

main.Foo{Type:[]string{"Bar"}}

Should we consider the issue fixed?

@ainar-g
Copy link
Contributor Author

ainar-g commented Aug 23, 2017

@ianlancetaylor This seems fixed. Should I close the issue? Or should someone first check, if the case is covered in tests?

@ianlancetaylor
Copy link
Contributor

I think this was probably fixed by https://golang.org/cl/30946, which has test cases, so, closing.

@golang golang locked and limited conversation to collaborators Aug 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge Suggested Issues that may be good for new contributors looking for work to do.
Projects
None yet
Development

No branches or pull requests

4 participants