From f789f94dbbb4d47bb2624aa2ace6e87eec649374 Mon Sep 17 00:00:00 2001 From: "Tim J. Robbins" Date: Thu, 13 May 2004 03:08:28 +0000 Subject: [PATCH] Fix braino in previous: check that the second byte in the character buffer is non-null when the character is two bytes long, not when the buffer is two bytes long. --- lib/libc/locale/big5.c | 2 +- lib/libc/locale/gbk.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libc/locale/big5.c b/lib/libc/locale/big5.c index 8eb4b522bc7..9e7f1f2baaf 100644 --- a/lib/libc/locale/big5.c +++ b/lib/libc/locale/big5.c @@ -118,7 +118,7 @@ _BIG5_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n, if (n == 0 || (size_t)(len = _big5_check(*s)) > n) /* Incomplete multibyte sequence */ return ((size_t)-2); - if (n == 2 && s[1] == '\0') { + if (len == 2 && s[1] == '\0') { errno = EILSEQ; return ((size_t)-1); } diff --git a/lib/libc/locale/gbk.c b/lib/libc/locale/gbk.c index 2038720fa09..d2f32c19d19 100644 --- a/lib/libc/locale/gbk.c +++ b/lib/libc/locale/gbk.c @@ -115,7 +115,7 @@ _GBK_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n, if (n == 0 || (size_t)(len = _gbk_check(*s)) > n) /* Incomplete multibyte sequence */ return ((size_t)-2); - if (n == 2 && s[1] == '\0') { + if (len == 2 && s[1] == '\0') { errno = EILSEQ; return ((size_t)-1); }