Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions ext/mbstring/php_mbregex.c
Original file line number Diff line number Diff line change
Expand Up @@ -1691,8 +1691,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];
Expand All @@ -1705,7 +1705,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);
Expand Down
22 changes: 22 additions & 0 deletions ext/mbstring/tests/bug76999.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
Bug #76999 (mb-regex-set-options return current options)
--SKIPIF--
<?php
if (!extension_loaded('mbstring')) die('skip mbstring extension not available');
if (!function_exists('mb_regex_set_options')) die('skip mb_regex_set_options() not available');
?>
--FILE--
<?php
mb_regex_set_options("pr");
var_dump(mb_regex_set_options("m"));
var_dump(mb_regex_set_options("mdi"));
var_dump(mb_regex_set_options("m"));
var_dump(mb_regex_set_options("a"));
var_dump(mb_regex_set_options());
?>
--EXPECT--
string(2) "pr"
string(2) "mr"
string(3) "imd"
string(2) "mr"
string(1) "r"