# HG changeset patch # User Rob Landley # Date 1405912126 18000 # Node ID 3fb99aaae28bf1561c01202ab6230268d9a1f851 # Parent e0c9c5424864b48e00cb4d29affa631d8efece9f Don't go into an endless loop if we hit a bad utf8 sequence without -q. diff -r e0c9c5424864 -r 3fb99aaae28b toys/posix/ls.c --- a/toys/posix/ls.c Sun Jul 20 21:34:49 2014 -0500 +++ b/toys/posix/ls.c Sun Jul 20 22:08:46 2014 -0500 @@ -75,12 +75,12 @@ len = mbrtowc(&c, s, MB_CUR_MAX, 0); if (len < 1 || (width = wcwidth(c)) < 0) { total++; - if (toys.optflags & FLAG_q) *(s++) = '?'; - - continue; + if (toys.optflags & FLAG_q) *s = '?'; + s++; + } else { + s += len; + total += width; } - s += len; - total += width; } return total;