diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
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.
Diffstat (limited to '')
| -rw-r--r-- | source/ui-stats.c | 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 4 insertions, 2 deletions
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)); |
