summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/locale/wcrtomb.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/libc/locale/wcrtomb.c b/lib/libc/locale/wcrtomb.c
index 116dce5..a76f031 100644
--- a/lib/libc/locale/wcrtomb.c
+++ b/lib/libc/locale/wcrtomb.c
@@ -28,6 +28,7 @@
__FBSDID("$FreeBSD$");
#include <errno.h>
+#include <limits.h>
#include <rune.h>
#include <stdlib.h>
#include <wchar.h>
@@ -36,7 +37,10 @@ size_t
wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps __unused)
{
char *e;
+ char buf[MB_LEN_MAX];
+ if (s == NULL)
+ s = buf;
sputrune(wc, s, MB_CUR_MAX, &e);
if (e == NULL) {
errno = EILSEQ;
OpenPOWER on IntegriCloud