static char *
get_posix_locale (void)
{
- const char *locale;
+ char *locale;
locale = g_getenv ("LC_ALL");
if (locale == NULL) {
locale = g_getenv ("LANG");
- if (locale == NULL)
- locale = setlocale (LC_ALL, NULL);
+ if (locale == NULL) {
+ char *static_locale = setlocale (LC_ALL, NULL);
+ if (static_locale)
+ locale = g_strdup (static_locale);
+ }
}
if (locale == NULL)
return NULL;
/* Skip English-only locale 'C' */
- if (strcmp (locale, "C") == 0)
+ if (strcmp (locale, "C") == 0) {
+ g_free (locale);
return NULL;
+ }
- return g_strdup (locale);
+ return locale;
}