diff options
author | Gianluca Arbezzano <ciao@gianarb.it> | 2021-06-25 15:40:24 +0200 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2021-06-25 10:24:08 -0400 |
commit | e566294050776355ca0d3bfd7a1f6f70767cd08b (patch) | |
tree | 7010c442c2677125bef67682a66213c3914a146b | |
parent | f13edb5dfd882ce608d61cf6b6740650ce9d84a3 (diff) |
Check for error value in url.Parse
I noticed I get a panic when running openring with http://antirez.com/rss
The panic happened because the url.Parse returned error is not assigned
to a variable.
<antirez>
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1119fd6]
goroutine 1 [running]:
net/url.(*URL).ResolveReference(0xc0004c0bd0, 0x0, 0x0)
/usr/local/Cellar/go/1.16.5/libexec/src/net/url/url.go:1075 +0x36
main.main()
/Users/gianarb/git/openring/openring.go:152 +0x9c
There is another problem, the URL is not valid for the url.Parse
function for some reason. But this is an issue for another day.
Signed-off-by: Gianluca Arbezzano <ciao@gianarb.it>
-rw-r--r-- | openring.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/openring.go b/openring.go index 994b608..e1865b8 100644 --- a/openring.go +++ b/openring.go @@ -130,7 +130,7 @@ func main() { if err != nil { log.Fatal("failed parsing update URL of the feed") } - feedLink, _ := url.Parse(feed.Link) + feedLink, err := url.Parse(feed.Link) if err != nil { log.Fatal("failed parsing canonical feed URL of the feed") } |