diff options
Diffstat (limited to 'lib/libc/string/wcsxfrm.c')
-rw-r--r-- | lib/libc/string/wcsxfrm.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libc/string/wcsxfrm.c b/lib/libc/string/wcsxfrm.c index 4e988af..5e47ad9 100644 --- a/lib/libc/string/wcsxfrm.c +++ b/lib/libc/string/wcsxfrm.c @@ -97,16 +97,20 @@ wcsxfrm(wchar_t * __restrict dest, const wchar_t * __restrict src, size_t len) static char * __mbsdup(const wchar_t *ws) { + static const mbstate_t initial; + mbstate_t st; const wchar_t *wcp; size_t len; char *mbs; wcp = ws; - if ((len = wcsrtombs(NULL, &wcp, 0, NULL)) == (size_t)-1) + st = initial; + if ((len = wcsrtombs(NULL, &wcp, 0, &st)) == (size_t)-1) return (NULL); if ((mbs = malloc(len + 1)) == NULL) return (NULL); - wcsrtombs(mbs, &ws, len + 1, NULL); + st = initial; + wcsrtombs(mbs, &ws, len + 1, &st); return (mbs); } |