From c59d7441e1d55e2065d63f280643aa4ca4f34323 Mon Sep 17 00:00:00 2001 From: djm Date: Sat, 23 Aug 2008 07:51:35 +0000 Subject: [PATCH] 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@ --- lib/libc/locale/multibyte_sb.c | 5 +++-- 1 file 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); } -- 2.20.1