Skip to content

Commit b6fdb60

Browse files
Stephen A. Zarkosweltling
Stephen A. Zarkos
authored andcommitted
Fixed PCRE locale crash in Windows/TS
1 parent 656fcb6 commit b6fdb60

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

ext/pcre/php_pcre.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,18 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(char *regex, int regex_le
244244
int count = 0;
245245
unsigned const char *tables = NULL;
246246
#if HAVE_SETLOCALE
247-
char *locale = setlocale(LC_CTYPE, NULL);
247+
char *locale;
248248
#endif
249249
pcre_cache_entry *pce;
250250
pcre_cache_entry new_entry;
251251

252+
#if HAVE_SETLOCALE
253+
# ifdef PHP_WIN32 && ZTS
254+
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
255+
# endif
256+
locale = setlocale(LC_CTYPE, NULL);
257+
#endif
258+
252259
/* Try to lookup the cached regex entry, and if successful, just pass
253260
back the compiled pattern, otherwise go on and compile it. */
254261
if (zend_hash_find(&PCRE_G(pcre_cache), regex, regex_len+1, (void **)&pce) == SUCCESS) {

0 commit comments

Comments
 (0)