From 3aa4269dde5a06b0684bcb3ee2f786879ab1360e Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Wed, 15 Jul 2026 13:52:05 -1000 Subject: Fix the stats year label and a missing author The year period rendered without its label, and a commit with no author line crashed the view. --- source/ui-stats.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source/ui-stats.c') diff --git a/source/ui-stats.c b/source/ui-stats.c index 02c60ef..ce6a26a 100644 --- a/source/ui-stats.c +++ b/source/ui-stats.c @@ -162,7 +162,7 @@ int cgit_find_stats_period(const char *expr, const struct cgit_period **period) const char *cgit_find_stats_periodname(int idx) { - if (idx > 0 && idx < 4) + if (idx > 0 && idx <= (int)ARRAY_SIZE(periods)) return periods[idx - 1].name; else return ""; @@ -181,7 +181,9 @@ static void add_commit(struct string_list *authors, struct commit *commit, uintptr_t *counter; info = cgit_parse_commit(commit); - tmp = xstrdup(info->author); + /* A commit can lack an author header, so fall back rather than + * xstrdup(NULL). */ + tmp = xstrdup(info->author ? info->author : "(unknown)"); author = string_list_insert(authors, tmp); if (!author->util) author->util = xcalloc(1, sizeof(struct authorstat)); -- cgit v2.8.0