From 583efa1268dfc7b55ec568903d4fd8027ec7db0f Mon Sep 17 00:00:00 2001 From: "Tim J. Robbins" Date: Fri, 25 Oct 2002 13:24:45 +0000 Subject: [PATCH] Use an internal buffer for the result when the first argument is NULL. --- lib/libc/locale/wcrtomb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/libc/locale/wcrtomb.c b/lib/libc/locale/wcrtomb.c index 116dce52c81e..a76f03159386 100644 --- a/lib/libc/locale/wcrtomb.c +++ b/lib/libc/locale/wcrtomb.c @@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include @@ -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;