]> Savannah Git Hosting - gnulib.git/commitdiff
localename: Fix crash on mingw (regression from 2018-11-23).
authorBruno Haible <bruno@clisp.org>
Sat, 27 Apr 2019 18:00:29 +0000 (20:00 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 27 Apr 2019 18:00:29 +0000 (20:00 +0200)
* lib/localename.c (gl_locale_name_posix): Don't attempt to convert a
locale name that is null.

ChangeLog
lib/localename.c

index 2aeef2e7f31e1141dc6e02dcb10fbf84407b9851..98b9c6c87e6385b60cbef03f3dde4b72acba6094 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+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.
+
 2019-04-27  Bruno Haible  <bruno@clisp.org>
 
        Fix gcc warnings on 64-bit mode mingw.
index 1cb0a90f0df25f096b271b7994053ff1f91e1957..1b1bb19bb828a7562069ccad49509350b26745ef 100644 (file)
@@ -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;
   }