summaryrefslogtreecommitdiff
path: root/lib/localename.c
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2019-04-27 20:00:29 +0200
committerBruno Haible <bruno@clisp.org>2019-04-27 20:00:29 +0200
commit00991ec9b670feb41b3726f1d7e7ff59b95e1317 (patch)
tree76717e013c91eb332a8b99afd4c23986306f374b /lib/localename.c
parent7ffb59a71322feee0c29c6ba46e100cc2c90cb08 (diff)
downloadgnulib-00991ec9b670feb41b3726f1d7e7ff59b95e1317.tar.gz
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.
Diffstat (limited to 'lib/localename.c')
-rw-r--r--lib/localename.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/localename.c b/lib/localename.c
index 1cb0a90f0d..1b1bb19bb8 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;
}