Reset MBREX(search_re) in RSHUTDOWN

This is going to cause a segfault if reused in the next request.
To illustrate the issue, run these two scripts in sequence with
the built-in server:

// script1.php
mb_ereg_search_init('foobar');
mb_ereg_search('foo');

// script2.php
var_dump(mb_ereg_search_init("foobar"));
var_dump(mb_ereg_search_pos());
This commit is contained in:
Nikita Popov 2020-01-29 16:03:44 +01:00
parent 392ad206a4
commit 560ff9725e

View file

@ -149,6 +149,7 @@ PHP_RSHUTDOWN_FUNCTION(mb_regex)
ZVAL_UNDEF(&MBREX(search_str));
}
MBREX(search_pos) = 0;
MBREX(search_re) = NULL;
if (MBREX(search_regs) != NULL) {
onig_region_free(MBREX(search_regs), 1);