Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-doc
Path: blob/main/website/static/security/patches/EN-15:09/xlocale.patch
18096 views
1
Index: lib/libc/locale/setrunelocale.c
2
===================================================================
3
--- lib/libc/locale/setrunelocale.c (revision 284940)
4
+++ lib/libc/locale/setrunelocale.c (working copy)
5
@@ -202,6 +202,8 @@ __set_thread_rune_locale(locale_t loc)
6
7
if (loc == NULL) {
8
_ThreadRuneLocale = &_DefaultRuneLocale;
9
+ } else if (loc == LC_GLOBAL_LOCALE) {
10
+ _ThreadRuneLocale = 0;
11
} else {
12
_ThreadRuneLocale = XLOCALE_CTYPE(loc)->runes;
13
}
14
Index: lib/libc/locale/xlocale.c
15
===================================================================
16
--- lib/libc/locale/xlocale.c (revision 284940)
17
+++ lib/libc/locale/xlocale.c (working copy)
18
@@ -154,23 +154,24 @@ __get_locale(void)
19
static void
20
set_thread_locale(locale_t loc)
21
{
22
+ locale_t l = (loc == LC_GLOBAL_LOCALE) ? 0 : loc;
23
24
_once(&once_control, init_key);
25
26
- if (NULL != loc) {
27
- xlocale_retain((struct xlocale_refcounted*)loc);
28
+ if (NULL != l) {
29
+ xlocale_retain((struct xlocale_refcounted*)l);
30
}
31
locale_t old = pthread_getspecific(locale_info_key);
32
- if ((NULL != old) && (loc != old)) {
33
+ if ((NULL != old) && (l != old)) {
34
xlocale_release((struct xlocale_refcounted*)old);
35
}
36
if (fake_tls) {
37
- thread_local_locale = loc;
38
+ thread_local_locale = l;
39
} else {
40
- pthread_setspecific(locale_info_key, loc);
41
+ pthread_setspecific(locale_info_key, l);
42
}
43
#ifndef __NO_TLS
44
- __thread_locale = loc;
45
+ __thread_locale = l;
46
__set_thread_rune_locale(loc);
47
#endif
48
}
49
@@ -361,9 +362,6 @@ locale_t uselocale(locale_t loc)
50
{
51
locale_t old = get_thread_locale();
52
if (NULL != loc) {
53
- if (LC_GLOBAL_LOCALE == loc) {
54
- loc = NULL;
55
- }
56
set_thread_locale(loc);
57
}
58
return (old ? old : LC_GLOBAL_LOCALE);
59
60