From: Anatol Belski Date: Tue, 21 Nov 2017 19:15:30 +0000 (+0100) Subject: Merge branch 'PHP-7.2' X-Git-Tag: php-7.3.0alpha1~982 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=54e7b0a6f77badba4385aabea6ebb656817df4f4;p=php Merge branch 'PHP-7.2' * PHP-7.2: Fixed #75539 and #74183 - preg_last_error not returning error code after error --- 54e7b0a6f77badba4385aabea6ebb656817df4f4 diff --cc ext/pcre/php_pcre.c index f23202ba18,aa2695ea2c..fd9f20d4a3 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@@ -712,8 -506,8 +716,9 @@@ PHPAPI pcre_cache_entry* pcre_get_compi zend_string_release(key); } #endif - php_error_docref(NULL,E_WARNING, "Compilation failed: %s at offset %d", error, erroffset); + pcre2_get_error_message(errnumber, error, sizeof(error)); + php_error_docref(NULL,E_WARNING, "Compilation failed: %s at offset %zu", error, erroffset); + pcre_handle_exec_error(PCRE_ERROR_INTERNAL); efree(pattern); if (tables) { pefree((void*)tables, 1); @@@ -724,18 -518,33 +729,19 @@@ #ifdef HAVE_PCRE_JIT_SUPPORT if (PCRE_G(jit)) { /* Enable PCRE JIT compiler */ - do_study = 1; - soptions |= PCRE_STUDY_JIT_COMPILE; - } -#endif - - /* If study option was specified, study the pattern and - store the result in extra for passing to pcre_exec. */ - if (do_study) { - extra = pcre_study(re, soptions, &error); - if (extra) { - extra->flags |= PCRE_EXTRA_MATCH_LIMIT | PCRE_EXTRA_MATCH_LIMIT_RECURSION; - extra->match_limit = (unsigned long)PCRE_G(backtrack_limit); - extra->match_limit_recursion = (unsigned long)PCRE_G(recursion_limit); -#ifdef HAVE_PCRE_JIT_SUPPORT - if (PCRE_G(jit) && jit_stack) { - pcre_assign_jit_stack(extra, NULL, jit_stack); + rc = pcre2_jit_compile(re, PCRE2_JIT_COMPLETE); + if (EXPECTED(rc >= 0)) { + size_t jit_size = 0; + if (!pcre2_pattern_info(re, PCRE2_INFO_JITSIZE, &jit_size) && jit_size > 0) { + poptions |= PREG_JIT; } -#endif - } - if (error != NULL) { - php_error_docref(NULL, E_WARNING, "Error while studying pattern"); + } else { + pcre2_get_error_message(rc, error, sizeof(error)); + php_error_docref(NULL, E_WARNING, "JIT compilation failed: %s", error); + pcre_handle_exec_error(PCRE_ERROR_INTERNAL); } - } else { - extra = NULL; } - +#endif efree(pattern); /* @@@ -765,7 -574,8 +771,8 @@@ zend_string_release(key); } #endif - php_error_docref(NULL, E_WARNING, "Internal pcre_fullinfo() error %d", rc); + php_error_docref(NULL, E_WARNING, "Internal pcre2_pattern_info() error %d", rc); + pcre_handle_exec_error(PCRE_ERROR_INTERNAL); return NULL; } @@@ -776,7 -586,8 +783,8 @@@ zend_string_release(key); } #endif - php_error_docref(NULL, E_WARNING, "Internal pcre_fullinfo() error %d", rc); + php_error_docref(NULL, E_WARNING, "Internal pcre_pattern_info() error %d", rc); + pcre_handle_exec_error(PCRE_ERROR_INTERNAL); return NULL; }