X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/042887faee685e7b2ad2ee466b72d5ab30e2bc54..cc4f900e0582d430332661211e30d2b82df82fde:/ext/POSIX/POSIX.xs diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs index 90d7a3d..2972c6d 100644 --- a/ext/POSIX/POSIX.xs +++ b/ext/POSIX/POSIX.xs @@ -572,7 +572,7 @@ static int not_here(const char *s); # undef c99_trunc #endif -#ifdef WIN32 +#ifdef _MSC_VER /* Some APIs exist under Win32 with "underbar" names. */ # undef c99_hypot @@ -3329,10 +3329,15 @@ mblen(s, n) #endif CODE: #if defined(USE_ITHREADS) && defined(HAS_MBRLEN) - PERL_UNUSED_RESULT(mbrlen(NULL, 0, &ps)); /* Initialize state */ + 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 @@ -3669,7 +3674,8 @@ strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1) #else /* If can't check directly, at least can see if script is consistent, under UTF-8, which gives us an extra measure of confidence. */ - && isSCRIPT_RUN((const U8 *) buf, buf + len, + && isSCRIPT_RUN((const U8 *) buf, + (const U8 *) buf + len, TRUE) /* Means assume UTF-8 */ #endif )) {