Path: blob/main/website/static/security/patches/EN-15:09/xlocale.patch
18096 views
Index: lib/libc/locale/setrunelocale.c1===================================================================2--- lib/libc/locale/setrunelocale.c (revision 284940)3+++ lib/libc/locale/setrunelocale.c (working copy)4@@ -202,6 +202,8 @@ __set_thread_rune_locale(locale_t loc)56if (loc == NULL) {7_ThreadRuneLocale = &_DefaultRuneLocale;8+ } else if (loc == LC_GLOBAL_LOCALE) {9+ _ThreadRuneLocale = 0;10} else {11_ThreadRuneLocale = XLOCALE_CTYPE(loc)->runes;12}13Index: lib/libc/locale/xlocale.c14===================================================================15--- lib/libc/locale/xlocale.c (revision 284940)16+++ lib/libc/locale/xlocale.c (working copy)17@@ -154,23 +154,24 @@ __get_locale(void)18static void19set_thread_locale(locale_t loc)20{21+ locale_t l = (loc == LC_GLOBAL_LOCALE) ? 0 : loc;2223_once(&once_control, init_key);2425- if (NULL != loc) {26- xlocale_retain((struct xlocale_refcounted*)loc);27+ if (NULL != l) {28+ xlocale_retain((struct xlocale_refcounted*)l);29}30locale_t old = pthread_getspecific(locale_info_key);31- if ((NULL != old) && (loc != old)) {32+ if ((NULL != old) && (l != old)) {33xlocale_release((struct xlocale_refcounted*)old);34}35if (fake_tls) {36- thread_local_locale = loc;37+ thread_local_locale = l;38} else {39- pthread_setspecific(locale_info_key, loc);40+ pthread_setspecific(locale_info_key, l);41}42#ifndef __NO_TLS43- __thread_locale = loc;44+ __thread_locale = l;45__set_thread_rune_locale(loc);46#endif47}48@@ -361,9 +362,6 @@ locale_t uselocale(locale_t loc)49{50locale_t old = get_thread_locale();51if (NULL != loc) {52- if (LC_GLOBAL_LOCALE == loc) {53- loc = NULL;54- }55set_thread_locale(loc);56}57return (old ? old : LC_GLOBAL_LOCALE);585960