From: djm Date: Sat, 23 Aug 2008 07:51:35 +0000 (+0000) Subject: make mbstowcs(NULL, string, 0) correctly return the length of the X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c59d7441e1d55e2065d63f280643aa4ca4f34323;p=openbsd 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@ --- 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); }