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

Unmarshaling arrays panics #384

Closed
x-hgg-x opened this issue Apr 30, 2020 · 0 comments · Fixed by #385
Closed

Unmarshaling arrays panics #384

x-hgg-x opened this issue Apr 30, 2020 · 0 comments · Fixed by #385

Comments

@x-hgg-x
Copy link
Contributor

x-hgg-x commented Apr 30, 2020

Describe the bug
Unmarshaling panics:

panic: reflect.MakeSlice of non-slice type

goroutine 1 [running]:
reflect.MakeSlice(0x566460, 0x513e20, 0x4, 0x4, 0x4ead48, 0x510560, 0x8)
        /usr/local/go/src/reflect/value.go:2256 +0x1d8
github.com/pelletier/go-toml.(*Decoder).valueFromOtherSlice(0xc00011ff10, 0x566460, 0x513e20, 0xc000022240, 0x4, 0x4, 0xc00011f838, 0xc00011f6a0, 0x4c99b3, 0xc0001101e0, ...)
        /projects/go-toml/marshal.go:786 +0x5f
github.com/pelletier/go-toml.(*Decoder).valueFromToml(0xc00011ff10, 0x566460, 0x513e20, 0x50dee0, 0xc00000c260, 0xc00000c280, 0x191, 0x0, 0x0, 0xc000014200, ...)
        /projects/go-toml/marshal.go:856 +0x527
github.com/pelletier/go-toml.(*Decoder).valueFromTree(0xc00011ff10, 0x566460, 0x51c080, 0xc000068480, 0xc00011fe10, 0x199, 0xc00005c2a0, 0x0, 0xc00011fdb0, 0x4f2dba)
        /projects/go-toml/marshal.go:694 +0x1174
github.com/pelletier/go-toml.(*Decoder).unmarshal(0xc00011ff10, 0x50a900, 0xc0000141f8, 0xc000068480, 0x0)
        /projects/go-toml/marshal.go:638 +0x275
github.com/pelletier/go-toml.(*Tree).Unmarshal(...)
        /projects/go-toml/marshal.go:525
main.main()
        /projects/go-toml/cmd/example/main.go:18 +0x13f

To Reproduce

type element struct {
	Color [4]uint8
}

tree, _ := toml.Load(`color = [1,2,3,4]`)

var e element
err := tree.Unmarshal(&e)
if err != nil {
	fmt.Println("unmarshal error:", err)
}

Expected behavior
There should be no panic.

Versions

  • go-toml: last version of master (2b8e33f)
  • go: 1.14
  • operating system: Linux

Additional context
None.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant