summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2020-03-15 22:17:32 -0600
committerKarl Williamson <khw@cpan.org>2020-03-18 18:12:39 -0600
commitd848c629501c573e92befef804a2ebd1d7bd3def (patch)
tree6ce7868add5a24462355a750ad59327fc07d2191 /util.c
parent133a66aff08799249b0b2cd73d7236402fa94870 (diff)
downloadperl-d848c629501c573e92befef804a2ebd1d7bd3def.tar.gz
Perl_init_tm: Use mutex to avoid race.
This locks around localtime (and localtime_r which this call may be translated into) which are sensitive to locale and environment changes in their execution.
Diffstat (limited to 'util.c')
-rw-r--r--util.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/util.c b/util.c
index e968aceca4..3b910965aa 100644
--- a/util.c
+++ b/util.c
@@ -3637,9 +3637,11 @@ Perl_init_tm(pTHX_ struct tm *ptm) /* see mktime, strftime and asctime */
PERL_UNUSED_CONTEXT;
PERL_ARGS_ASSERT_INIT_TM;
(void)time(&now);
+ ENV_LOCALE_READ_LOCK;
my_tm = localtime(&now);
if (my_tm)
Copy(my_tm, ptm, 1, struct tm);
+ ENV_LOCALE_READ_UNLOCK;
#else
PERL_UNUSED_CONTEXT;
PERL_ARGS_ASSERT_INIT_TM;