From 6c6cfd39b22f9ff28223688cbd2f18d298d8bdbf Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 19 Oct 2020 09:50:16 -0600 Subject: [PATCH] rktio: avoid `nl_langinfo_l` Using `nl_langinfo_l` crashes the "unicode.rktl" test on Linux. I don't know how `nl_langinfo_l` was being misused, but it's easy to just avoid it. --- racket/src/rktio/rktio_convert.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/racket/src/rktio/rktio_convert.c b/racket/src/rktio/rktio_convert.c index 1bc535fa54..019dbb7dfa 100644 --- a/racket/src/rktio/rktio_convert.c +++ b/racket/src/rktio/rktio_convert.c @@ -356,10 +356,12 @@ static char *nl_langinfo_dup(rktio_t *rktio) { char *s; # if HAVE_CODESET -# ifdef RKTIO_USE_XLOCALE - s = nl_langinfo_l(CODESET, rktio->locale); -# else +# if defined(RKTIO_USE_XLOCALE) + locale_t old_l = uselocale(rktio->locale); +# endif s = nl_langinfo(CODESET); +# if defined(RKTIO_USE_XLOCALE) + uselocale(old_l); # endif # else /* nl_langinfo doesn't work, so just make up something */