diff options
Diffstat (limited to 'lib/libc/locale/wctomb.c')
-rw-r--r-- | lib/libc/locale/wctomb.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/libc/locale/wctomb.c b/lib/libc/locale/wctomb.c index ca5ed8d..2a225f4 100644 --- a/lib/libc/locale/wctomb.c +++ b/lib/libc/locale/wctomb.c @@ -37,6 +37,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <errno.h> #include <stdlib.h> #include <limits.h> #include <stddef.h> @@ -58,5 +59,9 @@ wctomb(s, wchar) } sputrune(wchar, s, MB_CUR_MAX, &e); - return (e ? e - s : -1); + if (e == NULL) { + errno = EILSEQ; + return (-1); + } + return (e - s); } |