From: Bernhard Übelacker bernhardu@mailbox.org
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55467 --- dlls/msvcrt/locale.c | 2 ++ dlls/msvcrt/tests/locale.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+)
diff --git a/dlls/msvcrt/locale.c b/dlls/msvcrt/locale.c index f7be2a1e9bc..99cd82b29c9 100644 --- a/dlls/msvcrt/locale.c +++ b/dlls/msvcrt/locale.c @@ -2037,6 +2037,8 @@ char* CDECL setlocale(int category, const char* locale) thread_data_t *data = msvcrt_get_thread_data(); pthreadlocinfo locinfo = get_locinfo(), newlocinfo;
+ grab_locinfo(locinfo); + if(category<LC_MIN || category>LC_MAX) return NULL;
diff --git a/dlls/msvcrt/tests/locale.c b/dlls/msvcrt/tests/locale.c index f77e8f93abb..6a6bc5b8cc7 100644 --- a/dlls/msvcrt/tests/locale.c +++ b/dlls/msvcrt/tests/locale.c @@ -796,6 +796,25 @@ static void test___mb_cur_max_func(void) } }
+static DWORD WINAPI test_setlocale_threads_proc(void *arg) +{ + const char* locale = NULL; + if ((intptr_t)arg % 2) locale = "German_Germany.1252"; + setlocale(LC_NUMERIC, locale); + return 0; +} + +static void test_setlocale_threads(void) +{ + HANDLE threads[64]; + for (intptr_t i = 0; i < ARRAY_SIZE(threads); i++) + { + threads[i] = CreateThread(NULL, 0, test_setlocale_threads_proc, (void*)i, 0, NULL); + ok(threads[i] != NULL, "CreateThread failed\n"); + } + WaitForMultipleObjects(ARRAY_SIZE(threads), threads, TRUE, INFINITE); +} + START_TEST(locale) { init(); @@ -804,4 +823,5 @@ START_TEST(locale) test_setlocale(); test__Gettnames(); test___mb_cur_max_func(); + test_setlocale_threads(); }