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

bug: serpent.UrlOf may cause a panic when parsing url from env #14

Open
johnstcn opened this issue May 3, 2024 · 0 comments
Open

bug: serpent.UrlOf may cause a panic when parsing url from env #14

johnstcn opened this issue May 3, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@johnstcn
Copy link
Member

johnstcn commented May 3, 2024

It appears that when parsing a URL from the environment, serpent does not dereference it properly when embedded in a struct:

FROBNICATE_URL=http://foo.bar go run main.go 
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x10083be74]

goroutine 1 [running]:
github.com/coder/serpent.(*URL).Set(0x0, {0x1400001608f?, 0x100849e0a?})
	/Users/cian/go/pkg/mod/github.com/coder/serpent@v0.7.0/values.go:277 +0x34
github.com/coder/serpent.(*OptionSet).ParseEnv(0x140000ba280, {0x1400027a000, 0x23, 0x10064b324?})
	/Users/cian/go/pkg/mod/github.com/coder/serpent@v0.7.0/option.go:287 +0x240
github.com/coder/serpent.(*Invocation).run(0x140001d4200, 0x1400025fca8)
	/Users/cian/go/pkg/mod/github.com/coder/serpent@v0.7.0/command.go:289 +0x58
github.com/coder/serpent.(*Invocation).Run(0x140001d4200)
	/Users/cian/go/pkg/mod/github.com/coder/serpent@v0.7.0/command.go:536 +0x128
main.main()
	/Users/cian/tmp/serpent-url-panic/main.go:40 +0x268
exit status 2

Sample Go program to reproduce: https://go.dev/play/p/K9uNgbvGM0J

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant