summaryrefslogtreecommitdiff
path: root/locale.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2022-12-01 10:44:08 -0700
committerKarl Williamson <khw@cpan.org>2022-12-05 11:54:43 -0700
commit2a9ab842f968d5b791dda641c9aff2396fd1f024 (patch)
tree41ee9e4820cce0fe34e25eb02fb0dc2285fbf9e3 /locale.c
parent86665b00d95547847396212c376467ff98778ef2 (diff)
downloadperl-2a9ab842f968d5b791dda641c9aff2396fd1f024.tar.gz
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.
Diffstat (limited to 'locale.c')
-rw-r--r--locale.c4
1 files changed, 4 insertions, 0 deletions
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;