summaryrefslogtreecommitdiff
path: root/chromium/third_party/icu/patches/timezone.patch
blob: bf7e1729aef4fd9bf74e6febb7ac388ff9769031 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
diff --git a/source/i18n/timezone.cpp b/source/i18n/timezone.cpp
index f129d8b6..32214d72 100644
--- a/source/i18n/timezone.cpp
+++ b/source/i18n/timezone.cpp
@@ -527,6 +527,11 @@ TimeZone::detectHostTimeZone()
 
 // -------------------------------------
 
+static UMutex *gDefaultZoneMutex() {
+    static UMutex* m = new UMutex();
+    return m;
+}
+
 /**
  * Initialize DEFAULT_ZONE from the system default time zone.  
  * Upon return, DEFAULT_ZONE will not be NULL, unless operator new()
@@ -536,6 +541,7 @@ static void U_CALLCONV initDefault()
 {
     ucln_i18n_registerCleanup(UCLN_I18N_TIMEZONE, timeZone_cleanup);
 
+    Mutex lock(gDefaultZoneMutex());
     // If setDefault() has already been called we can skip getting the
     // default zone information from the system.
     if (DEFAULT_ZONE != NULL) {
@@ -571,7 +577,10 @@ TimeZone* U_EXPORT2
 TimeZone::createDefault()
 {
     umtx_initOnce(gDefaultZoneInitOnce, initDefault);
-    return (DEFAULT_ZONE != NULL) ? DEFAULT_ZONE->clone() : NULL;
+    {
+        Mutex lock(gDefaultZoneMutex());
+        return (DEFAULT_ZONE != NULL) ? DEFAULT_ZONE->clone() : NULL;
+    }
 }
 
 // -------------------------------------
@@ -581,9 +590,12 @@ TimeZone::adoptDefault(TimeZone* zone)
 {
     if (zone != NULL)
     {
-        TimeZone *old = DEFAULT_ZONE;
-        DEFAULT_ZONE = zone;
-        delete old;
+        {
+            Mutex lock(gDefaultZoneMutex());
+            TimeZone *old = DEFAULT_ZONE;
+            DEFAULT_ZONE = zone;
+            delete old;
+        }
         ucln_i18n_registerCleanup(UCLN_I18N_TIMEZONE, timeZone_cleanup);
     }
 }