nlopess Sat Mar 8 13:14:02 2008 UTC
Modified files:
/php-src/ext/pcre php_pcre.c
/php-src/ext/pcre/tests bug44214.phpt bug44214_2.phpt
Log:
MFB: fix #44214
http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/php_pcre.c?r1=1.232&r2=1.233&diff_format=u
Index: php-src/ext/pcre/php_pcre.c
diff -u php-src/ext/pcre/php_pcre.c:1.232 php-src/ext/pcre/php_pcre.c:1.233
--- php-src/ext/pcre/php_pcre.c:1.232 Sat Mar 8 11:59:44 2008
+++ php-src/ext/pcre/php_pcre.c Sat Mar 8 13:14:02 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_pcre.c,v 1.232 2008/03/08 11:59:44 nlopess Exp $ */
+/* $Id: php_pcre.c,v 1.233 2008/03/08 13:14:02 nlopess Exp $ */
/* TODO
* php_pcre_replace_impl():
@@ -969,8 +969,8 @@
result_len = offsets[1] - offsets[0];
*result = estrndup(&subject[offsets[0]], result_len);
}
- zval_dtor(subpats);
- FREE_ZVAL(subpats);
+
+ zval_ptr_dtor(&subpats);
return result_len;
}
http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/tests/bug44214.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/pcre/tests/bug44214.phpt
diff -u /dev/null php-src/ext/pcre/tests/bug44214.phpt:1.2
--- /dev/null Sat Mar 8 13:14:02 2008
+++ php-src/ext/pcre/tests/bug44214.phpt Sat Mar 8 13:14:02 2008
@@ -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"
+ }
+}
http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/tests/bug44214_2.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/pcre/tests/bug44214_2.phpt
diff -u /dev/null php-src/ext/pcre/tests/bug44214_2.phpt:1.2
--- /dev/null Sat Mar 8 13:14:02 2008
+++ php-src/ext/pcre/tests/bug44214_2.phpt Sat Mar 8 13:14:02 2008
@@ -0,0 +1,25 @@
+--TEST--
+Bug #44214-2 (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[0];
+ 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]=>
+ string(3) "aaa"
+ [1]=>
+ string(3) "aaa"
+}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php