All wx apps crash because of nl_langinfo(CODESET) returns garbage

Corinna Vinschen corinna-cygwin@cygwin.com
Wed Mar 1 09:19:00 GMT 2017


On Mar  1 07:56, Kolya Kosenko wrote:
> All wxWidgets-based application crash because call
> nl_langinfo(CODESET) returns sometimes garbage during wxWidgets
> initialization at
> /usr/src/debug/wxWidgets3.0-3.0.2.0-2/src/common/intl.cpp:811:
>     char *oldLocale = strdup(setlocale(LC_CTYPE, NULL));
>     setlocale(LC_CTYPE, "");
>     const char *alang = nl_langinfo(CODESET);
>     setlocale(LC_CTYPE, oldLocale);
>     free(oldLocale);
> alang variable is not null and garbage here! It causes wxWidgets
> assertion failure at wxString::FromAscii().

At first sight this looks like a bug to me.  The information returned by
nl_langinfo is only guaranteed to be stable if you don't call setlocale
or nl_langinfo again.  If you need the result of nl_langinfo(CODESET)
even after calling setlocale again, you have to strdup it.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20170301/a0bfa19a/attachment.sig>


More information about the Cygwin mailing list