summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2008-08-23 07:51:36 +0000
committerDamien Miller <djm@cvs.openbsd.org>2008-08-23 07:51:36 +0000
commitd7f320c3bdfc3ed5b2b87d533c02b0b76e0cf16c (patch)
tree20e4b888603a530ffcf653683f9ef41944a474b0 /lib
parent6f9398b097c437a2e59e019eb677450e778c9ecf (diff)
make mbstowcs(NULL, string, 0) correctly return the length of the
wchar_t string needed to represent "string", which in our case is just strlen(string); feedback & "looks right" deraadt@
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/locale/multibyte_sb.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/libc/locale/multibyte_sb.c b/lib/libc/locale/multibyte_sb.c
index 6f11625315d..4067b154b02 100644
--- a/lib/libc/locale/multibyte_sb.c
+++ b/lib/libc/locale/multibyte_sb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: multibyte_sb.c,v 1.6 2005/12/10 02:01:51 deraadt Exp $ */
+/* $OpenBSD: multibyte_sb.c,v 1.7 2008/08/23 07:51:35 djm Exp $ */
/* $NetBSD: multibyte_sb.c,v 1.4 2003/08/07 16:43:04 agc Exp $ */
/*
@@ -132,7 +132,8 @@ mbstowcs(wchar_t *pwcs, const char *s, size_t n)
{
/* pwcs may be NULL */
- /* s may be NULL */
+ if (pwcs == NULL)
+ return strlen(s);
return mbsrtowcs(pwcs, &s, n, NULL);
}