Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Invalid simple_keys now cause panics later in decode #548

@cjcullen

Description

@cjcullen

Looks like a test case that I missed in #543.

The following test in unmarshalErrorTests in decode_test.go passes before that PR, and fails after.

	{"a:\n  1:\nb\n  2:", ".*could not find expected ':'"},

I get a panic:

$ go test
...
... Panic: attempted to parse unknown event: none (PC=0x42FD21)

/usr/lib/google-golang/src/runtime/panic.go:679
  in gopanic
yaml.go:249
  in handleErr
/usr/lib/google-golang/src/runtime/panic.go:679
  in gopanic
decode.go:158
  in parser.parse
decode.go:217
  in parser.mapping
decode.go:149
  in parser.parse
decode.go:217
  in parser.mapping
decode.go:149
  in parser.parse
decode.go:175
  in parser.document
decode.go:153
  in parser.parse
yaml.go:142
  in unmarshal
yaml.go:81
  in Unmarshal
decode_test.go:889
  in S.TestUnmarshalErrors
/usr/lib/google-golang/src/reflect/value.go:321
  in Value.Call
/usr/lib/google-golang/src/runtime/asm_amd64.s:1357
  in goexit
OOPS: 30 passed, 2 PANICKED
--- FAIL: Test (2.83s)
FAIL
exit status 1
FAIL	gopkg.in/yaml.v2	2.885s

I think we are no longer catching the "stale" case now that we only process the simple_keys stack from the top.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions