small pixel drawing of a pufferfish jrss

Fix potential for null pointer dereference
j3s j3s@c3f.net
Mon, 15 Feb 2021 16:31:04 -0600
commit

f05a8892ba5070ba8c2e6121e3224457ea6cb6f4

parent

f5e614fb152a6a914c952da8a6255a8bfa1cda67

1 files changed, 4 insertions(+), 7 deletions(-)

jump to
M main.gomain.go

@@ -19,7 +19,7 @@ if err != nil {

log.Fatal(err) } posts := make([]gofeed.Feed, 0) - var gottenFeed gofeed.Feed + var gottenFeed *gofeed.Feed for _, f := range feeds { gottenFeed, err = getFeed(f) if err != nil {

@@ -28,7 +28,7 @@ // feed fetching failure

log.Println(err) continue } - posts = append(posts, gottenFeed) + posts = append(posts, *gottenFeed) } beegFeed := gofeed.Feed{} for _, p := range posts {

@@ -44,13 +44,10 @@ fmt.Fprintf(w, "<p>%s: <a href=\"%s\">%s</a></p>", i.Description, i.Link, i.Title)

} } -func getFeed(url string) (post gofeed.Feed, err error) { +func getFeed(url string) (*gofeed.Feed, error) { fp := gofeed.NewParser() feed, err := fp.ParseURL(url) - if err != nil { - log.Println(err) - } - return *feed, err + return feed, err } func getFeedList(url string) ([]string, error) {