summaryrefslogtreecommitdiff
path: root/ext/POSIX/POSIX.xs
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2019-04-03 13:17:56 -0600
committerKarl Williamson <khw@cpan.org>2019-04-09 12:02:20 -0600
commitcc4f900e0582d430332661211e30d2b82df82fde (patch)
treedb2a79e9c38a4487b7d88d11219b9d978d6fe226 /ext/POSIX/POSIX.xs
parent97198b3000a99efbf375de01c8622a33cc9d92a5 (diff)
downloadperl-cc4f900e0582d430332661211e30d2b82df82fde.tar.gz
Make POSIX::mblen() slightly safer
by using a mutex around its call
Diffstat (limited to 'ext/POSIX/POSIX.xs')
-rw-r--r--ext/POSIX/POSIX.xs5
1 files changed, 5 insertions, 0 deletions
diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs
index 27051c1fdb..2972c6d91d 100644
--- a/ext/POSIX/POSIX.xs
+++ b/ext/POSIX/POSIX.xs
@@ -3332,7 +3332,12 @@ mblen(s, n)
memset(&ps, 0, sizeof(ps)); /* Initialize state */
RETVAL = mbrlen(s, n, &ps); /* Prefer reentrant version */
#else
+ /* This might prevent some races, but locales can be switched out
+ * without locking, so this isn't a cure all */
+ LOCALE_LOCK;
+
RETVAL = mblen(s, n);
+ LOCALE_UNLOCK;
#endif
OUTPUT:
RETVAL