Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Open
@johnstcn

Description

@johnstcn

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/[email protected]/values.go:277 +0x34
github.com/coder/serpent.(*OptionSet).ParseEnv(0x140000ba280, {0x1400027a000, 0x23, 0x10064b324?})
	/Users/cian/go/pkg/mod/github.com/coder/[email protected]/option.go:287 +0x240
github.com/coder/serpent.(*Invocation).run(0x140001d4200, 0x1400025fca8)
	/Users/cian/go/pkg/mod/github.com/coder/[email protected]/command.go:289 +0x58
github.com/coder/serpent.(*Invocation).Run(0x140001d4200)
	/Users/cian/go/pkg/mod/github.com/coder/[email protected]/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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions