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

v2: panic unmarshaling inline table to string #850

Closed
NathanBaulch opened this issue Feb 20, 2023 · 1 comment · Fixed by #853
Closed

v2: panic unmarshaling inline table to string #850

NathanBaulch opened this issue Feb 20, 2023 · 1 comment · Fixed by #853
Labels
bug Issues describing a bug in go-toml.

Comments

@NathanBaulch
Copy link

Describe the bug

panic: subslice address (0) is before data address (824636779408)
goroutine 1 [running]:
github.com/pelletier/go-toml/v2/internal/danger.SubsliceOffset({0xc0002eab90, 0x8, 0x8}, {0x0, 0x0, 0x0})
        C:/Users/Nathan/go/pkg/mod/github.com/pelletier/go-toml/v2@v2.0.6/internal/danger/danger.go:16 +0x273
github.com/pelletier/go-toml/v2.wrapDecodeError({0xc0002eab90, 0x8, 0x8}, 0xc0002cd0c0)
        C:/Users/Nathan/go/pkg/mod/github.com/pelletier/go-toml/v2@v2.0.6/errors.go:91 +0x5c
github.com/pelletier/go-toml/v2.(*decoder).FromParser(0xc000207f00, {0xea01a0?, 0xc00000a4b8?})
        C:/Users/Nathan/go/pkg/mod/github.com/pelletier/go-toml/v2@v2.0.6/unmarshaler.go:216 +0x24c
github.com/pelletier/go-toml/v2.Unmarshal({0xc0002eab90, 0x8, 0x8}, {0xea01a0, 0xc00000a4b8})
        C:/Users/Nathan/go/pkg/mod/github.com/pelletier/go-toml/v2@v2.0.6/unmarshaler.go:28 +0x11a
main.main()

To Reproduce

data := make(map[string]string)
_ = toml.Unmarshal([]byte("foo = {}"), &data)

Expected behavior
A meaningful error.

Versions

  • go-toml: v2.0.6
  • go: 1.19
  • operating system: Windows

Additional context
Similar to #581 and #588.

pelletier added a commit that referenced this issue Feb 28, 2023
Parser did not track the location of the faulty inline table in the
document, and unmarshaler tried to the use the non-raw data field of the
AST node, both resulting into a panic when generating the parser error.

Fixes #850
@pelletier pelletier added the bug Issues describing a bug in go-toml. label Feb 28, 2023
pelletier added a commit that referenced this issue Feb 28, 2023
Parser did not track the location of the faulty inline table in the
document, and unmarshaler tried to the use the non-raw data field of the
AST node, both resulting into a panic when generating the parser error.

Fixes #850
@pelletier
Copy link
Owner

Thanks for reporting this bug! I've merged 8a416da, which should correct the problem. Feel free to reopen this issue if it doesn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues describing a bug in go-toml.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants