From 03d03243fa09634895378923b53360e40a608c82 Mon Sep 17 00:00:00 2001 From: ju1ius Date: Sat, 30 Jul 2016 13:55:46 +0200 Subject: Fix #72711: `mb_ereg` does not clear the `$regs` parameter on failure When `mb_ereg` failed to match, it didn't update the `$regs` argument. Now it will always set it to the empty array. --- ext/mbstring/php_mbregex.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'ext/mbstring/php_mbregex.c') diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index db37bd3739..a9e464fa64 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -713,6 +713,11 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase) RETURN_FALSE; } + if (array != NULL) { + zval_dtor(array); + array_init(array); + } + options = MBREX(regex_default_options); if (icase) { options |= ONIG_OPTION_IGNORECASE; @@ -751,8 +756,6 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase) match_len = 1; str = string; if (array != NULL) { - zval_dtor(array); - array_init(array); match_len = regs->end[0] - regs->beg[0]; for (i = 0; i < regs->num_regs; i++) { -- cgit v1.2.1