This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
locale.c: Add critical section
authorKarl Williamson <khw@cpan.org>
Thu, 15 Feb 2018 12:41:51 +0000 (05:41 -0700)
committerKarl Williamson <khw@cpan.org>
Sun, 18 Feb 2018 18:31:08 +0000 (11:31 -0700)
This code should be protected from another thread doing the same thing
nearly simultaneously, so that the static buffer doesn't get zapped in
this system call.

locale.c

index 1fcfa26..4a3d3a0 100644 (file)
--- a/locale.c
+++ b/locale.c
@@ -3448,10 +3448,12 @@ Perl__is_cur_LC_category_utf8(pTHX_ int category)
 
 #      else
 
+            LOCALE_LOCK;
             PERL_UNUSED_RESULT(mbtowc(&wc, NULL, 0));/* Reset any shift state */
             SETERRNO(0, 0);
             len = mbtowc(&wc, STR_WITH_LEN(REPLACEMENT_CHARACTER_UTF8));
             SAVE_ERRNO;
+            LOCALE_UNLOCK;
 
 #      endif