summaryrefslogtreecommitdiff
path: root/ext/mbstring/php_mbregex.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-01-29 12:50:40 +0100
committerNikita Popov <nikita.ppv@gmail.com>2020-01-29 12:50:40 +0100
commitb3f07afabc32cef19c092524fd705ca1cbde566b (patch)
tree68142f60ae31a62adea660230ff54d135d462761 /ext/mbstring/php_mbregex.c
parent5589bf4d4af830b2a081475cf8065bf1ed9cf19a (diff)
parent392ad206a4f63fedf61d8086e390c73de8b72767 (diff)
downloadphp-git-b3f07afabc32cef19c092524fd705ca1cbde566b.tar.gz
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix use of mb_ereg_search_getregs() after invalid pattern
Diffstat (limited to 'ext/mbstring/php_mbregex.c')
-rw-r--r--ext/mbstring/php_mbregex.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c
index 366aad23cf..11f63858b2 100644
--- a/ext/mbstring/php_mbregex.c
+++ b/ext/mbstring/php_mbregex.c
@@ -1440,6 +1440,11 @@ _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode)
_php_mb_regex_init_options(arg_options, arg_options_len, &option, &syntax, NULL);
}
+ if (MBREX(search_regs)) {
+ onig_region_free(MBREX(search_regs), 1);
+ MBREX(search_regs) = NULL;
+ }
+
if (arg_pattern) {
/* create regex pattern buffer */
if ((MBREX(search_re) = php_mbregex_compile_pattern(arg_pattern, arg_pattern_len, option, MBREX(current_mbctype), MBREX(regex_default_syntax))) == NULL) {
@@ -1465,9 +1470,6 @@ _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode)
RETURN_FALSE;
}
- if (MBREX(search_regs)) {
- onig_region_free(MBREX(search_regs), 1);
- }
MBREX(search_regs) = onig_region_new();
err = _php_mb_onig_search(MBREX(search_re), str, str + len, str + pos, str + len, MBREX(search_regs), 0);