From c509d9bcbb015e1408dd0a0a61a13fbf82fd081e Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Fri, 19 Jun 2020 00:00:00 -0500 Subject: [PATCH] top: provide for zero length character in utf8 support This commit is prompted by the preceding change to the library's escape.c module which, in turn, was prompted by that issue shown below (with thanks to Konstantin). Reference(s): https://gitlab.com/procps-ng/procps/-/issues/176 Signed-off-by: Jim Warner --- top/top.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/top/top.c b/top/top.c index 9ac3a454..cc6f4f0c 100644 --- a/top/top.c +++ b/top/top.c @@ -710,7 +710,8 @@ static inline int utf8_cols (const unsigned char *p, int n) { if (n > 1) { (void)mbtowc(&wc, (const char *)p, n); - if ((n = wcwidth(wc)) < 1) n = 1; + // allow a zero as valid, as with a 'combining acute accent' + if ((n = wcwidth(wc)) < 0) n = 1; } return n; #else -- 2.50.0