Skip to content

Commit 57f33b4

Browse files
committed
Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1: Fix yet one data race in PCRE
2 parents d4af204 + 1b29dc0 commit 57f33b4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ext/pcre/php_pcre.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ PHPAPI ZEND_DECLARE_MODULE_GLOBALS(pcre)
6868
#define PCRE_JIT_STACK_MAX_SIZE (64 * 1024)
6969
ZEND_TLS pcre_jit_stack *jit_stack = NULL;
7070
#endif
71-
#if defined(ZTS) && defined(HAVE_PCRE_JIT_SUPPORT)
71+
#if defined(ZTS)
7272
static MUTEX_T pcre_mt = NULL;
7373
#define php_pcre_mutex_alloc() if (tsrm_is_main_thread() && !pcre_mt) pcre_mt = tsrm_mutex_alloc();
7474
#define php_pcre_mutex_free() if (tsrm_is_main_thread() && pcre_mt) tsrm_mutex_free(pcre_mt); pcre_mt = NULL;
@@ -544,7 +544,9 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
544544
/* If study option was specified, study the pattern and
545545
store the result in extra for passing to pcre_exec. */
546546
if (do_study) {
547+
php_pcre_mutex_lock();
547548
extra = pcre_study(re, soptions, &error);
549+
php_pcre_mutex_unlock();
548550
if (extra) {
549551
extra->flags |= PCRE_EXTRA_MATCH_LIMIT | PCRE_EXTRA_MATCH_LIMIT_RECURSION;
550552
extra->match_limit = (unsigned long)PCRE_G(backtrack_limit);

0 commit comments

Comments
 (0)