com php-src: Merge branch 'PHP-7.2': ext/pcre/php_pcre.c
| From: | Anatol Belski | Date: | Tue, 21 Nov 2017 19:15:30 +0000 |
| Subject: | com php-src: Merge branch 'PHP-7.2': ext/pcre/php_pcre.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-100324@lists.php.net to get a copy of this message | ||
Commit: 54e7b0a6f77badba4385aabea6ebb656817df4f4
Author: Anatol Belski <ab@php.net> Tue, 21 Nov 2017 20:15:30 +0100
Parents: 12b2c2f5f9f3f31f6276aac35365932d9032e839 f6b0d365a709ae71cd9f77b25c337a6e6883f68d
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=54e7b0a6f77badba4385aabea6ebb656817df4f4
Log:
Merge branch 'PHP-7.2'
* PHP-7.2:
Fixed #75539 and #74183 - preg_last_error not returning error code after error
Bugs:
https://bugs.php.net/75539
https://bugs.php.net/74183
Changed paths:
MM ext/pcre/php_pcre.c
Diff:
diff --cc ext/pcre/php_pcre.c
index f23202b,aa2695e..fd9f20d
--- 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;
}