summaryrefslogtreecommitdiff
path: root/lib/mbswidth.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-12-08 18:31:38 +0000
committerJim Meyering <jim@meyering.net>2000-12-08 18:31:38 +0000
commita05267197a0e9af4e48516aa6a977bca1c4fcce5 (patch)
tree56fa73c7440b3dad6e9dfaf82ce29fd01d850979 /lib/mbswidth.c
parenta90e5f5a69cd5a52fca2931a3fdc37858927f73d (diff)
downloadcoreutils-a05267197a0e9af4e48516aa6a977bca1c4fcce5.tar.xz
(mbsnwidth): Don't loop endlessly when called with an
invalid mulitbyte sequence and with the MBSW_ACCEPT_INVALID flag set.
Diffstat (limited to 'lib/mbswidth.c')
-rw-r--r--lib/mbswidth.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/mbswidth.c b/lib/mbswidth.c
index f196ac18d..bb6aa1a6d 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;
}