From 004bab1de661eacf8fc661094e609849b39abb98 Mon Sep 17 00:00:00 2001 From: Will Brown Date: Sat, 8 Feb 2025 13:54:46 -0500 Subject: [PATCH] [main.c] Fix adding empty feeds If there are no items in a feed, set the last_pubDate variable to 0 instead of dereferencing a null pointer (oops) --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index d78480c..ba165ec 100644 --- a/main.c +++ b/main.c @@ -258,7 +258,8 @@ static void bot_command_add(struct discord *client, const struct discord_interac } feed.title = mrss_feed->title; - feed.last_pubDate = mrss_feed->item->pubDate; + // if there are no entries, set the last pubDate to zero. + feed.last_pubDate = mrss_feed->item ? mrss_feed->item->pubDate : 0; zblock_feed_info_err insert_res = zblock_feed_info_insert(database_conn, &feed); if (insert_res) {