diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-07-02 15:25:36 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-07-02 15:29:03 -0700 |
commit | e70413657a514ed9e9367fa43daa2cbff3fa4a2c (patch) | |
tree | a244e746a00c4007c349fc5487501f3679abecb6 | |
parent | d3612d7578a3597443e51a5527fd4a3175fc4ba9 (diff) |
cherry-pick musl 1.1.3 wcsxfrm.c, fixes #2473
-rw-r--r-- | system/lib/libc/musl/src/locale/wcsxfrm.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/system/lib/libc/musl/src/locale/wcsxfrm.c b/system/lib/libc/musl/src/locale/wcsxfrm.c index cb79c97e..5d89e7dd 100644 --- a/system/lib/libc/musl/src/locale/wcsxfrm.c +++ b/system/lib/libc/musl/src/locale/wcsxfrm.c @@ -6,10 +6,12 @@ size_t __wcsxfrm_l(wchar_t *restrict dest, const wchar_t *restrict src, size_t n, locale_t loc) { size_t l = wcslen(src); - if (l >= n) { + if (l < n) { + wmemcpy(dest, src, l+1); + } else if (n) { wmemcpy(dest, src, n-1); dest[n-1] = 0; - } else wcscpy(dest, src); + } return l; } |