incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: [PATCH] STDCXX-93
Date Thu, 05 Oct 2006 15:59:07 GMT
Farid Zaripov wrote:
>   Attached is a patch for resolve issue STDCXX-93.
[...]
> Index: time_put.cpp
> ===================================================================
> --- time_put.cpp	(revision 453153)
> +++ time_put.cpp	(working copy)
> @@ -725,8 +725,12 @@
>          const char *str =
>              _RWSTD_STATIC_CAST (const char*, pun->abday (t.tm_wday, 0));
>  
> +        _RWSTD_ASSERT (0 != str);
> +
> +        _RWSTD_SIZE_T size = 1 + strlen (str);
> +
>          wchar_t *pwbuf = _RWSTD_REINTERPRET_CAST (wchar_t*, pbuf + off);
> -        _RWSTD_SIZE_T size = mbstowcs (pwbuf, str, _RWSTD_SIZE_MAX);
> +        size = mbstowcs (pwbuf, str, size);

I don't think this is quite correct (even if it's safe).

The last argument to mbstowcs() is the maximum number of elements
in the destination buffer that the function can write. The length
of the second argument (in bytes) might be greater than the number
of multibyte characters in the string, which in turn might be even
greater than the number of wide characters that correspond to it.

We should either pass in the size of the destination buffer or
some large value that windows can deal with.

Martin

Mime
View raw message