diff --git a/NEWS b/NEWS index c05493cc846..83ef93e59de 100644 --- a/NEWS +++ b/NEWS @@ -56,6 +56,7 @@ PHP NEWS . Removed deprecated ldap_sort. (mcmic) - MBString: + . Fixed bug #76999 (mb_regex_set_options() return current options). (cmb) . Removed the unused $is_hex parameter from mb_decode_numericentity(). (cmb) - MySQLi: diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index ceda96398ea..bcdff2c4c95 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -1682,8 +1682,8 @@ static void _php_mb_regex_set_options(OnigOptionType options, OnigSyntaxType *sy Set or get the default options for mbregex functions */ PHP_FUNCTION(mb_regex_set_options) { - OnigOptionType opt; - OnigSyntaxType *syntax; + OnigOptionType opt, prev_opt; + OnigSyntaxType *syntax, *prev_syntax; char *string = NULL; size_t string_len; char buf[16]; @@ -1696,7 +1696,9 @@ PHP_FUNCTION(mb_regex_set_options) opt = 0; syntax = NULL; _php_mb_regex_init_options(string, string_len, &opt, &syntax, NULL); - _php_mb_regex_set_options(opt, syntax, NULL, NULL); + _php_mb_regex_set_options(opt, syntax, &prev_opt, &prev_syntax); + opt = prev_opt; + syntax = prev_syntax; } else { opt = MBREX(regex_default_options); syntax = MBREX(regex_default_syntax); diff --git a/ext/mbstring/tests/bug76999.phpt b/ext/mbstring/tests/bug76999.phpt new file mode 100644 index 00000000000..5ba9f0e8e38 --- /dev/null +++ b/ext/mbstring/tests/bug76999.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #76999 (mb_regex_set_options() return current options) +--SKIPIF-- + +--FILE-- + +--EXPECT-- +string(2) "pr" +string(2) "mr" +string(3) "imd" +string(2) "mr" +string(1) "r"