From 740e585b9db4ac170aded76b8ba25557e7bd517f Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Thu, 18 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 fbb2f610..626b5b80 100644 --- a/top/top.c +++ b/top/top.c @@ -544,7 +544,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