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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ PHP NEWS
- MBString:
. Fixed bug GH-22779 (mb_strrpos() returns the wrong position for a negative
offset in a non-UTF-8 encoding). (Eyüp Can Akman)
. Fixed bug GH-21036 (mb_ereg_search_getregs() crashes after mb_eregi()
invalidates the regex cache). (Matthias Goergens)

- PCRE:
. Fixed bug GH-21134 (Crash with \C + UTF-8). Using \C in UTF-8 patterns is
Expand Down
4 changes: 4 additions & 0 deletions ext/mbstring/php_mbregex.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,10 @@ static php_mb_regex_t *php_mbregex_compile_pattern(const char *pattern, size_t p
if (rc == MBREX(search_re)) {
/* reuse the new rc? see bug #72399 */
MBREX(search_re) = NULL;
if (MBREX(search_regs) != NULL) {
onig_region_free(MBREX(search_regs), 1);
MBREX(search_regs) = NULL;
}
}
zend_hash_str_update_ptr(&MBREX(ht_rc), (char *)pattern, patlen, retval);
} else {
Expand Down
21 changes: 21 additions & 0 deletions ext/mbstring/tests/gh21036.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
GH-21036 (mb_ereg_search_getregs() after regex cache invalidation)
--EXTENSIONS--
mbstring
Comment thread
youkidearitai marked this conversation as resolved.
--SKIPIF--
<?php
if (!function_exists("mb_ereg")) print "skip mb_ereg() not available";
?>
--FILE--
<?php
error_reporting(E_ALL & ~E_DEPRECATED);

$pattern = '(?<name>a)';
mb_ereg_search_init('a', $pattern);
mb_ereg_search_pos();
mb_eregi($pattern, 'a');

var_dump(mb_ereg_search_getregs());
?>
--EXPECT--
bool(false)
Loading