coder / coder/serpent

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

Open
#14 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
21
Forks
6
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.