[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)
This commit is contained in:
2025-02-08 13:54:46 -05:00
parent ef9c5caf4e
commit 004bab1de6

3
main.c
View File

@ -258,7 +258,8 @@ static void bot_command_add(struct discord *client, const struct discord_interac
} }
feed.title = mrss_feed->title; 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); zblock_feed_info_err insert_res = zblock_feed_info_insert(database_conn, &feed);
if (insert_res) { if (insert_res) {