Skip to content

Commit 52851c4

Browse files
committed
POSIX.xs: Add locks to libc functions missing them
Use these new macros to assure thread safety
1 parent 016342e commit 52851c4

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

ext/POSIX/POSIX.xs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,7 +1742,9 @@ fix_win32_tzenv(void)
17421742
newenv = (char*)malloc((strlen(perl_tz_env) + 4) * sizeof(char));
17431743
if (newenv != NULL) {
17441744
sprintf(newenv, "TZ=%s", perl_tz_env);
1745+
PERL_PUTENV_LOCK;
17451746
_putenv(newenv);
1747+
PERL_PUTENV_UNLOCK;
17461748
if (oldenv != NULL)
17471749
free(oldenv);
17481750
oldenv = newenv;
@@ -3390,7 +3392,9 @@ strtol(str, base = 0)
33903392
PPCODE:
33913393
CHECK_AND_WARN_PROBLEMATIC_LOCALE_;
33923394
if (base == 0 || inRANGE(base, 2, 36)) {
3395+
PERL_STRTOL_LOCK;
33933396
num = strtol(str, &unparsed, base);
3397+
PERL_STRTOL_UNLOCK;
33943398
#if IVSIZE < LONGSIZE
33953399
if (num < IV_MIN || num > IV_MAX)
33963400
PUSHs(sv_2mortal(newSVnv((NV)num)));
@@ -3425,7 +3429,9 @@ strtoul(str, base = 0)
34253429
PERL_UNUSED_VAR(base);
34263430
CHECK_AND_WARN_PROBLEMATIC_LOCALE_;
34273431
if (base == 0 || inRANGE(base, 2, 36)) {
3432+
PERL_STRTOUL_LOCK;
34283433
num = strtoul(str, &unparsed, base);
3434+
PERL_STRTOUL_UNLOCK;
34293435
#if UVSIZE < LONGSIZE
34303436
if (num > UV_MAX)
34313437
PUSHs(sv_2mortal(newSVnv((NV)num)));
@@ -3663,7 +3669,9 @@ cuserid(s = 0)
36633669
char * s = 0;
36643670
CODE:
36653671
#ifdef HAS_CUSERID
3672+
PERL_CUSERID_LOCK;
36663673
RETVAL = cuserid(s);
3674+
PERL_CUSERID_UNLOCK;
36673675
#else
36683676
PERL_UNUSED_VAR(s);
36693677
RETVAL = 0;

ext/POSIX/lib/POSIX.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use warnings;
44

55
our ($AUTOLOAD, %SIGRT);
66

7-
our $VERSION = '2.25';
7+
our $VERSION = '2.26';
88

99
require XSLoader;
1010

0 commit comments

Comments
 (0)