Piotr Caban : msvcrt: Lock global locale in _get_current_locale.
Alexandre Julliard
julliard at winehq.org
Wed Nov 18 15:48:02 CST 2020
Module: wine
Branch: master
Commit: 216b9cb080b00c5f477c0ced58c354e5714d5720
URL: https://source.winehq.org/git/wine.git/?a=commit;h=216b9cb080b00c5f477c0ced58c354e5714d5720
Author: Piotr Caban <piotr at codeweavers.com>
Date: Wed Nov 18 17:26:50 2020 +0100
msvcrt: Lock global locale in _get_current_locale.
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/msvcrt/locale.c | 35 +++++++++++++++++++----------------
1 file changed, 19 insertions(+), 16 deletions(-)
diff --git a/dlls/msvcrt/locale.c b/dlls/msvcrt/locale.c
index 8afac8aba87..dd9a7ce0930 100644
--- a/dlls/msvcrt/locale.c
+++ b/dlls/msvcrt/locale.c
@@ -1117,6 +1117,22 @@ void free_mbcinfo(MSVCRT_pthreadmbcinfo mbcinfo)
MSVCRT_free(mbcinfo);
}
+/*********************************************************************
+ * _lock_locales (UCRTBASE.@)
+ */
+void CDECL _lock_locales(void)
+{
+ _mlock(_SETLOCALE_LOCK);
+}
+
+/*********************************************************************
+ * _unlock_locales (UCRTBASE.@)
+ */
+void CDECL _unlock_locales(void)
+{
+ _munlock(_SETLOCALE_LOCK);
+}
+
MSVCRT__locale_t CDECL get_current_locale_noalloc(MSVCRT__locale_t locale)
{
thread_data_t *data = msvcrt_get_thread_data();
@@ -1124,6 +1140,7 @@ MSVCRT__locale_t CDECL get_current_locale_noalloc(MSVCRT__locale_t locale)
if(!data || !data->have_locale)
{
+ _lock_locales();
*locale = *MSVCRT_locale;
}
else
@@ -1144,6 +1161,8 @@ MSVCRT__locale_t CDECL get_current_locale_noalloc(MSVCRT__locale_t locale)
if(locale->locinfo->ctype1_refcount)
InterlockedIncrement(locale->locinfo->ctype1_refcount);
InterlockedIncrement(&locale->locinfo->lc_time_curr->refcount);
+ if(locale->locinfo == MSVCRT_locale->locinfo)
+ _unlock_locales();
InterlockedIncrement(&locale->mbcinfo->refcount);
return locale;
@@ -1930,22 +1949,6 @@ static MSVCRT_pthreadlocinfo create_locinfo(int category,
return locinfo;
}
-/*********************************************************************
- * _lock_locales (UCRTBASE.@)
- */
-void CDECL _lock_locales(void)
-{
- _mlock(_SETLOCALE_LOCK);
-}
-
-/*********************************************************************
- * _unlock_locales (UCRTBASE.@)
- */
-void CDECL _unlock_locales(void)
-{
- _munlock(_SETLOCALE_LOCK);
-}
-
/*********************************************************************
* _create_locale (MSVCRT.@)
*/
More information about the wine-cvs
mailing list