From 1dce3d25ed05cce7a562b231025ff64697b310d1 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 8 Dec 2000 18:31:38 +0000 Subject: [PATCH] (mbsnwidth): Don't loop endlessly when called with an invalid mulitbyte sequence and with the MBSW_ACCEPT_INVALID flag set. --- lib/mbswidth.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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; } -- 2.30.2