summaryrefslogtreecommitdiff
path: root/ext/pcre/tests/bug44214.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'ext/pcre/tests/bug44214.phpt')
-rw-r--r--ext/pcre/tests/bug44214.phpt31
1 files changed, 31 insertions, 0 deletions
diff --git a/ext/pcre/tests/bug44214.phpt b/ext/pcre/tests/bug44214.phpt
new file mode 100644
index 0000000..90e4c86
--- /dev/null
+++ b/ext/pcre/tests/bug44214.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Bug #44214 (crash with preg_replace_callback() and global variable)
+--FILE--
+<?php
+$string = 'aaa bbb ccc ddd eee ccc aaa bbb';
+
+$array = array();
+
+function myCallBack( $match ) {
+ global $array;
+ $array[] = $match;
+ return 'xxx';
+}
+
+var_dump(preg_replace_callback( '`a+`', 'myCallBack', $string));
+var_dump($array);
+?>
+--EXPECT--
+string(31) "xxx bbb ccc ddd eee ccc xxx bbb"
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "aaa"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "aaa"
+ }
+}