Skip to content

Commit

Permalink
locale.c: Add missing mutex locks
Browse files Browse the repository at this point in the history
This adds locks around mbrtowc and reading the environment that a code
review indicated were missing.  The mbrtowc lock is currently a no-op,
but a future commit will change that.  The other lock is in code rarely
compiled.
  • Loading branch information
khwilliamson committed Jul 16, 2023
1 parent e38e5c7 commit 010ea6c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions locale.c
Original file line number Diff line number Diff line change
Expand Up @@ -3186,7 +3186,9 @@ Perl_mbtowc_(pTHX_ const wchar_t * pwc, const char * s, const Size_t len)
# if defined(USE_MBRTOWC)

SETERRNO(0, 0);
MBRTOWC_LOCK_;
retval = (SSize_t) mbrtowc((wchar_t *) pwc, s, len, &PL_mbrtowc_ps);
MBRTOWC_UNLOCK_;

# else

Expand Down Expand Up @@ -5470,6 +5472,9 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
* form qr/ ^ LC_ [A-Z]+ = /x, except LC_ALL which was
* already handled above. These are assumed to be locale
* settings. Output them and their values. */

ENV_READ_LOCK;

for (e = environ; *e; e++) {
const STRLEN prefix_len = sizeof("LC_") - 1;
STRLEN uppers_len;
Expand All @@ -5485,6 +5490,8 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
*e + prefix_len + uppers_len + 1);
}
}

ENV_READ_UNLOCK;
}

# else
Expand Down

0 comments on commit 010ea6c

Please sign in to comment.