readr

Minimal Terminal RSS Reader
Log | Files | Refs | README | LICENSE

commit 18d6254c3ab9a711c55d91cd68ab3e800626d6dd
parent 88527d022bf353f1aac2542206de945fa5f60a5b
Author: citbl <citbl@citbl.org>
Date:   Thu, 16 Jul 2026 23:02:49 +1000

1.11 handle edge cases of bad feed or title

Diffstat:
Msrc/config.h | 2+-
Msrc/render.c | 14++++++++++++--
2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/config.h b/src/config.h @@ -1,6 +1,6 @@ #pragma once -#define VERSION "v1.10" +#define VERSION "v1.11" // recommended, pass as chrome for reddit feeds #define USER_AGENT \ diff --git a/src/render.c b/src/render.c @@ -1,4 +1,8 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #include "termbox2.h" #include "tui.h" #include "config.h" @@ -108,12 +112,18 @@ render(app_t* app) } // domain - const char* domain_host = host_from_url(post->link); + char* domain_host = host_from_url(post->link); snprintf(domain, DOMAIN_CAP, "%s", domain_host ? domain_host : "(bad domain)"); + free(domain_host); int domain_len = (int)strlen(domain); // chop title to fit within its column and not overlap the domain - snprintf(title, width - domain_len - FEED_CAP - 6, "%s", title); + int title_space = width - domain_len - FEED_CAP - 6; + if (title_space <= 0) { + title[0] = '\0'; + } else if ((size_t)title_space < sizeof(title)) { + title[title_space - 1] = '\0'; + } if (app->selected_panel == 1 && j == app->selected_post) if (post->seen)