Hi,

the reverse function mbsrtowcs (mingw-w64-crt/misc/mbrtowc.c) suffers
from the same problem. This second patch fixes this function as well.

Regards,
Tim Kosse

On 2016-01-04 01:19, Tim Kosse wrote:
> Hi,
> 
> there's a bug in wcsrtombs (mingw-w64-crt/misc/wcrtomb.c) if null is
> passed as destination buffer. In this case, wcsrtombs does not ignore
> the len argument. Yet, according to the C99 standard, if the dst is
> null, the len argument is ignored.
> 
> The attached patch fixes this bug.
> 
> Regards,
> Tim Kosse
> 
diff --git a/mingw-w64-crt/misc/wcrtomb.c b/mingw-w64-crt/misc/wcrtomb.c
index 299f67b..e96d061 100644
--- a/mingw-w64-crt/misc/wcrtomb.c
+++ b/mingw-w64-crt/misc/wcrtomb.c
@@ -85,7 +85,7 @@ size_t wcsrtombs (char *dst, const wchar_t **src, size_t len,
   else
     {
       char byte_bucket [MB_LEN_MAX];
-      while (n < len)
+      while (1)
 	{
 	  if ((ret = __wcrtomb_cp (&byte_bucket[0], *pwc, cp, mb_max)) <= 0)
 	    return (size_t) -1;
------------------------------------------------------------------------------
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to