]> granicus.if.org Git - procps-ng/commitdiff
proc/escape.c: Handle negative wcwidth() return value.
authorQualys Security Advisory <qsa@qualys.com>
Thu, 1 Jan 1970 00:00:00 +0000 (00:00 +0000)
committerCraig Small <csmall@enc.com.au>
Fri, 18 May 2018 21:32:21 +0000 (07:32 +1000)
This should never happen, because wcwidth() is called only if iswprint()
returns nonzero. But belt-and-suspenders, and make it visually clear
(very important for the next patch).

proc/escape.c

index 51aa3af73e43ff054b915dbd5e6eeb9222283ab4..a846095b4637ff54352ae22d6f1c9734acd21336 100644 (file)
@@ -88,7 +88,7 @@ static int escape_str_utf8(char *restrict dst, const char *restrict src, int buf
       /* multibyte - printable */
       int wlen = wcwidth(wc);
 
-      if (wlen==0) {
+      if (wlen<=0) {
        // invisible multibyte -- we don't ignore it, because some terminal
        // interpret it wrong and more safe is replace it with '?'
        *(dst++) = '?';