From: Corinna Vinschen Date: Wed, 1 Apr 2015 13:31:18 +0000 (+0200) Subject: Fix UTF-16 surrogate handling in wctomb and friends. X-Git-Tag: cygwin-2_0_0-release~39 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=9b42474f293d068dcaa65f2f20ca268c51c960ec;p=newlib-cygwin.git Fix UTF-16 surrogate handling in wctomb and friends. * libc/stdlib/wctomb_r.c (__utf8_wctomb): Fix check for handling a lone high surrogate. Signed-off-by: Corinna Vinschen --- diff --git a/newlib/ChangeLog b/newlib/ChangeLog index e615421d1..a5a31c7b0 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,8 @@ +2015-04-01 Corinna Vinschen + + * libc/stdlib/wctomb_r.c (__utf8_wctomb): Fix check for handling a + lone high surrogate. + 2015-03-31 Corinna Vinschen * libc/time/lcltime_r.c (localtime_r): Call _tzset_unlocked inside diff --git a/newlib/libc/stdlib/wctomb_r.c b/newlib/libc/stdlib/wctomb_r.c index 13e1e4c36..c93962fa4 100644 --- a/newlib/libc/stdlib/wctomb_r.c +++ b/newlib/libc/stdlib/wctomb_r.c @@ -74,7 +74,7 @@ _DEFUN (__utf8_wctomb, (r, s, wchar, charset, state), return 0; /* UTF-8 encoding is not state-dependent */ if (sizeof (wchar_t) == 2 && state->__count == -4 - && (wchar < 0xdc00 || wchar >= 0xdfff)) + && (wchar < 0xdc00 || wchar > 0xdfff)) { /* There's a leftover lone high surrogate. Write out the CESU-8 value of the surrogate and proceed to convert the given character. Note diff --git a/winsup/cygwin/release/1.7.36 b/winsup/cygwin/release/1.7.36 index 21175c9ac..0515ef96e 100644 --- a/winsup/cygwin/release/1.7.36 +++ b/winsup/cygwin/release/1.7.36 @@ -35,3 +35,6 @@ Bug Fixes - Avoid potential crash at startup or in getgroups(2). Addresses: https://cygwin.com/ml/cygwin/2015-04/msg00010.html + +- Fix UTF-16 surrogate handling in wctomb and friends. + Addresses: https://cygwin.com/ml/cygwin/2015-03/msg00452.html