mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix use of mb_ereg_search_getregs() after invalid pattern
This commit is contained in:
commit
b3f07afabc
2 changed files with 22 additions and 3 deletions
|
@ -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);
|
_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) {
|
if (arg_pattern) {
|
||||||
/* create regex pattern buffer */
|
/* 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) {
|
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;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MBREX(search_regs)) {
|
|
||||||
onig_region_free(MBREX(search_regs), 1);
|
|
||||||
}
|
|
||||||
MBREX(search_regs) = onig_region_new();
|
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);
|
err = _php_mb_onig_search(MBREX(search_re), str, str + len, str + pos, str + len, MBREX(search_regs), 0);
|
||||||
|
|
17
ext/mbstring/tests/mb_ereg_search_invalid_pattern.phpt
Normal file
17
ext/mbstring/tests/mb_ereg_search_invalid_pattern.phpt
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
--TEST--
|
||||||
|
mb_ereg_search() with invalid pattern should discard old matches
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
mb_ereg_search_init('');
|
||||||
|
var_dump(mb_ereg_search(''));
|
||||||
|
var_dump(mb_ereg_search("\xff"));
|
||||||
|
var_dump(mb_ereg_search_getregs());
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
bool(true)
|
||||||
|
|
||||||
|
Warning: mb_ereg_search(): Pattern is not valid under UTF-8 encoding in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
bool(false)
|
Loading…
Add table
Add a link
Reference in a new issue