diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Prune the stats walk and guard its dates
Diffstat (limited to 'source/ui-stats.c')
| -rw-r--r-- | source/ui-stats.c | 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 9 insertions, 1 deletion
diff --git a/source/ui-stats.c b/source/ui-stats.c index f6d2637..3ae3034 100644 --- a/source/ui-stats.c +++ b/source/ui-stats.c @@ -190,7 +190,11 @@ static void add_commit(struct string_list *authors, struct commitinfo *info, authorstat = author->util; items = &authorstat->list; t = info->committer_date; - gmtime_r(&t, &date); + // A crafted commit can carry a date outside the range gmtime_r can + // represent, which would leave date uninitialized and later index + // the month table out of bounds. Drop such a commit from the stats. + if (!gmtime_r(&t, &date)) + return; period->trunc(&date); tmp = xstrdup(period->pretty(&date)); item = string_list_insert(items, tmp); @@ -246,6 +250,10 @@ static struct string_list collect_stats(const struct cgit_period *period) rev.verbose_header = 1; rev.show_root_diff = 0; setup_revisions(argc, argv, &rev, NULL); + // Prune the walk to the displayed window instead of traversing the + // whole history and discarding older commits. The in-process check + // below still bounds the period edge exactly. + rev.max_age = since; prepare_revision_walk(&rev); memset(&authors, 0, sizeof(authors)); while ((commit = get_revision(&rev)) != NULL) { |
