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

Recursive anchor causes stack overflow #353

Open
korylprince opened this issue Mar 6, 2023 · 0 comments
Open

Recursive anchor causes stack overflow #353

korylprince opened this issue Mar 6, 2023 · 0 comments

Comments

@korylprince
Copy link

The following yaml causes a stack overflow:

key1: &anchor
  subkey: *anchor
key2: *anchor

If you remove either the second or third line, it parses successfully. Here's a real-world example where this fails.

Here's a minimal example:

package main

import (
	"github.com/goccy/go-yaml"
)

type Key struct {
	SubKey *Key `yaml:"subkey"`
}

type Test struct {
	Key1 *Key `yaml:"key1"`
	Key2 *Key `yaml:"key2"`
}

var test = []byte(`
key1: &anchor
  subkey: *anchor
key2: *anchor
`)

func main() {
	t := new(Test)
	// causes stack overflow
	yaml.Unmarshal(test, t)
}
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

No branches or pull requests

1 participant