summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2002-10-25 13:24:45 +0000
committertjr <tjr@FreeBSD.org>2002-10-25 13:24:45 +0000
commit035cd9e947221591dd2631862ff84924ab3f4932 (patch)
tree172381160da385b0472ee430a06b3b8e51553641 /lib/libc
parent3f4f4ce1692fe9a30e8aa74190a75e1f59b34a80 (diff)
downloadFreeBSD-src-035cd9e947221591dd2631862ff84924ab3f4932.zip
FreeBSD-src-035cd9e947221591dd2631862ff84924ab3f4932.tar.gz
Use an internal buffer for the result when the first argument is NULL.
Diffstat (limited to 'lib/libc')
-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