From 560ff9725e6fb05942dd0c891c8a4496c57bcb4b Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 29 Jan 2020 16:03:44 +0100 Subject: 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()); --- ext/mbstring/php_mbregex.c | 1 + 1 file changed, 1 insertion(+) (limited to 'ext/mbstring/php_mbregex.c') diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index aa1eec1686..b6ed2b86e9 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -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); -- cgit v1.2.1