* localename: fix crash on mingw
@ 2019-04-27 18:01 Bruno Haible
0 siblings, 0 replies; only message in thread
From: Bruno Haible @ 2019-04-27 18:01 UTC (permalink / raw)
To: bug-gnulib
The localename test currently crashes on mingw.
This patch fixes it.
2019-04-27 Bruno Haible <bruno@clisp.org>
localename: Fix crash on mingw (regression from 2018-11-23).
* lib/localename.c (gl_locale_name_posix): Don't attempt to convert a
locale name that is null.
diff --git a/lib/localename.c b/lib/localename.c
index 1cb0a90..1b1bb19 100644
--- a/lib/localename.c
+++ b/lib/localename.c
@@ -3294,15 +3294,16 @@ gl_locale_name_posix (int category, const char *categoryname)
/* Convert the locale name from the format returned by setlocale() or found
in the environment variables to the XPG syntax. */
#if defined WINDOWS_NATIVE
- {
- /* Convert locale name to LCID. We don't want to use
- LocaleNameToLCID because (a) it is only available since Vista,
- and (b) it doesn't accept locale names returned by 'setlocale'. */
- LCID lcid = get_lcid (locname);
+ if (locname != NULL)
+ {
+ /* Convert locale name to LCID. We don't want to use
+ LocaleNameToLCID because (a) it is only available since Vista,
+ and (b) it doesn't accept locale names returned by 'setlocale'. */
+ LCID lcid = get_lcid (locname);
- if (lcid > 0)
- return gl_locale_name_from_win32_LCID (lcid);
- }
+ if (lcid > 0)
+ return gl_locale_name_from_win32_LCID (lcid);
+ }
#endif
return locname;
}
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-04-27 18:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-27 18:01 localename: fix crash on mingw Bruno Haible
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).