diff options
author | Anatol Belski <ab@php.net> | 2017-11-16 14:12:05 +0100 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2017-11-16 14:12:05 +0100 |
commit | a370a6af647e27a334676a2c87bf686c6c973423 (patch) | |
tree | 77779494b4ff088d940952cdc1a4a14dc1b0b0f7 /ext/pcre/php_pcre.c | |
parent | acaaf4608acd9d74b31d992a1afa94767fda912b (diff) | |
download | php-git-a370a6af647e27a334676a2c87bf686c6c973423.tar.gz |
Fix (*NO_JIT) usage when JIT is enabled
If (*NO_JIT) is put into the pattern, the JIT compilation will still
succeed but produce no code. The pattern will still have to be
interpreted and is not suitable for the JIT fast path. This means,
we still need to check the pattern info after JIT compilation and only
set the flags when the JIT code was produced.
Diffstat (limited to 'ext/pcre/php_pcre.c')
-rw-r--r-- | ext/pcre/php_pcre.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 5386077f8c..615cece7cf 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -726,7 +726,10 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex) /* Enable PCRE JIT compiler */ rc = pcre2_jit_compile(re, PCRE2_JIT_COMPLETE); if (EXPECTED(rc >= 0)) { - poptions |= PREG_JIT; + size_t jit_size = 0; + if (!pcre2_pattern_info(re, PCRE2_INFO_JITSIZE, &jit_size) && jit_size > 0) { + poptions |= PREG_JIT; + } } else { pcre2_get_error_message(rc, error, sizeof(error)); php_error_docref(NULL, E_WARNING, "JIT compilation failed: %s", error); |