libroot: Do not return LC_GLOBAL_LOCALE from __current_locale_t().
Not all things that accept locale_t can accept LC_GLOBAL_LOCALE, specifically nl_langinfo_l does not (the specification indicates that passing it is undefined behavior; indeed, no C library I glanced at seems to support that.) So, return a static locale_t pointing to the global values instead. Fixes #17875 and #17876.
This commit is contained in:
@@ -266,7 +266,12 @@ extern "C" locale_t
|
|||||||
__current_locale_t()
|
__current_locale_t()
|
||||||
{
|
{
|
||||||
locale_t locale = (locale_t)GetCurrentLocaleInfo();
|
locale_t locale = (locale_t)GetCurrentLocaleInfo();
|
||||||
if (locale == NULL)
|
if (locale == NULL) {
|
||||||
locale = LC_GLOBAL_LOCALE;
|
static LocaleBackendData global_locale_t;
|
||||||
|
global_locale_t.backend = gGlobalLocaleBackend;
|
||||||
|
global_locale_t.databridge = &gGlobalLocaleDataBridge;
|
||||||
|
return (locale_t)&global_locale_t;
|
||||||
|
}
|
||||||
|
|
||||||
return locale;
|
return locale;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user