]> granicus.if.org Git - php/commitdiff
Fixed PCRE locale crash in Windows/TS
authorStephen A. Zarkos <stephen.zarkos@microsoft.com>
Mon, 4 Mar 2013 08:09:45 +0000 (09:09 +0100)
committerAnatol Belski <ab@php.net>
Mon, 4 Mar 2013 08:09:45 +0000 (09:09 +0100)
ext/pcre/php_pcre.c

index b9cb4f4a7ccce3736e222acb9568c2f84105c3cb..cab3a4c8ddd5e457c1dd409ae8867e313c31d2f7 100644 (file)
@@ -244,11 +244,18 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(char *regex, int regex_le
        int                             count = 0;
        unsigned const char *tables = NULL;
 #if HAVE_SETLOCALE
-       char                            *locale = setlocale(LC_CTYPE, NULL);
+       char                            *locale;
 #endif
        pcre_cache_entry        *pce;
        pcre_cache_entry         new_entry;
 
+#if HAVE_SETLOCALE
+# ifdef PHP_WIN32 && ZTS
+       _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
+# endif
+       locale = setlocale(LC_CTYPE, NULL);
+#endif
+
        /* Try to lookup the cached regex entry, and if successful, just pass
           back the compiled pattern, otherwise go on and compile it. */
        if (zend_hash_find(&PCRE_G(pcre_cache), regex, regex_len+1, (void **)&pce) == SUCCESS) {