diff options
Diffstat (limited to 'lib/libc/string/wcscoll.c')
-rw-r--r-- | lib/libc/string/wcscoll.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libc/string/wcscoll.c b/lib/libc/string/wcscoll.c index b042a25..dbfbcfa 100644 --- a/lib/libc/string/wcscoll.c +++ b/lib/libc/string/wcscoll.c @@ -79,16 +79,20 @@ wcscoll(const wchar_t *ws1, const wchar_t *ws2) 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); } |