From: Jim Meyering Date: Fri, 8 Dec 2000 18:31:38 +0000 (+0000) Subject: (mbsnwidth): Don't loop endlessly when called with an X-Git-Tag: TEXTUTILS-2_0_10~37 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=a05267197a0e9af4e48516aa6a977bca1c4fcce5;p=thirdparty%2Fcoreutils.git (mbsnwidth): Don't loop endlessly when called with an invalid mulitbyte sequence and with the MBSW_ACCEPT_INVALID flag set. --- diff --git a/lib/mbswidth.c b/lib/mbswidth.c index f196ac18dc..bb6aa1a6d8 100644 --- a/lib/mbswidth.c +++ b/lib/mbswidth.c @@ -153,7 +153,11 @@ mbsnwidth (const char *string, size_t nbytes, int flags) /* An invalid multibyte sequence was encountered. */ { if (flags & MBSW_ACCEPT_INVALID) - break; + { + p++; + width++; + break; + } else return -1; } @@ -162,7 +166,11 @@ mbsnwidth (const char *string, size_t nbytes, int flags) /* An incomplete multibyte character at the end. */ { if (flags & MBSW_ACCEPT_INVALID) - break; + { + p = plimit; + width++; + break; + } else return -1; }