On Wed, Aug 10, 2022 at 12:56:11PM +0400, Alexander Meshcheryakov wrote: Thanks for digging. (And please, try to avoid top-posting here in this list) > I believe I have found exact place where strlen is used incorrectly > This is at diff.c:show_stats > > https://github.com/git/git/blob/c50926e1f48891e2671e1830dbcd2912a4563450/diff.c#L2623 > > It probably should be replaced with one of utf8_width, utf8_strnwidth > or utf8_strwidth from utf8.c That did not help here. If I understand it right, this function is not at all involved in our `git log --stat` ? I tried this patch (not 100% git-style) and didn't see any print. --- a/diff.c +++ b/diff.c @@ -2620,7 +2620,14 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options) continue; } fill_print_name(file); - len = strlen(file->print_name); + { + const char *cp = file->print_name; + size_t l = strlen(file->print_name); + len = utf8_width(&cp, &l); + fprintf(stderr, "%s/%s:%d file->print_name='%s' len=%lu\n", + __FILE__, __FUNCTION__, __LINE__, + file->print_name, (unsigned long)len); + } if (max_len < len) max_len = len; And looking here, it seems as we are calculating max_len here. Still more digging needed (but I don't promise anything today)