From 2a9ab842f968d5b791dda641c9aff2396fd1f024 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Thu, 1 Dec 2022 10:44:08 -0700 Subject: locale.c: Add mutex lock around _wsetlocale() call The lock expands to nothing if unthreaded, or thread-local storage is in effect. But otherwise protects a global value from being clobbered by another thread. --- locale.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'locale.c') diff --git a/locale.c b/locale.c index 93f97b1082..8c98b3269c 100644 --- a/locale.c +++ b/locale.c @@ -2609,14 +2609,18 @@ S_wrap_wsetlocale(pTHX_ const int category, const char *locale) } } + WSETLOCALE_LOCK; const wchar_t * wresult = _wsetlocale(category, wlocale); Safefree(wlocale); if (! wresult) { + WSETLOCALE_UNLOCK; return NULL; } const char * result = Win_wstring_to_utf8_string(wresult); + WSETLOCALE_UNLOCK; + SAVEFREEPV(result); /* is there something better we can do here? */ return result; -- cgit v1.2.1