This is a live mirror of the Perl 5 development currently hosted at
https://github.com/perl/perl5
https://perl5.git.perl.org
/
perl5.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
97198b3
)
Make POSIX::mblen() slightly safer
author
Karl Williamson
<khw@cpan.org>
Wed, 3 Apr 2019 19:17:56 +0000
(13:17 -0600)
committer
Karl Williamson
<khw@cpan.org>
Tue, 9 Apr 2019 18:02:20 +0000
(12:02 -0600)
by using a mutex around its call
ext/POSIX/POSIX.xs
patch
|
blob
|
blame
|
history
diff --git
a/ext/POSIX/POSIX.xs
b/ext/POSIX/POSIX.xs
index
27051c1
..
2972c6d
100644
(file)
--- 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