diff options
Diffstat (limited to 'chromium/third_party/icu/source/i18n')
-rw-r--r-- | chromium/third_party/icu/source/i18n/timezone.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/chromium/third_party/icu/source/i18n/timezone.cpp b/chromium/third_party/icu/source/i18n/timezone.cpp index f129d8b6076..129e6a5f27d 100644 --- a/chromium/third_party/icu/source/i18n/timezone.cpp +++ b/chromium/third_party/icu/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); } } |