nlopess Thu Aug 14 14:35:23 2008 UTC Modified files: /php-src/ext/pcre php_pcre.c /php-src/ext/pcre/tests bug44925.phpt Log: sync with 5.3 branch. add test for bug #44925 http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/php_pcre.c?r1=1.237&r2=1.238&diff_format=u Index: php-src/ext/pcre/php_pcre.c diff -u php-src/ext/pcre/php_pcre.c:1.237 php-src/ext/pcre/php_pcre.c:1.238 --- php-src/ext/pcre/php_pcre.c:1.237 Sat Aug 2 04:40:44 2008 +++ php-src/ext/pcre/php_pcre.c Thu Aug 14 14:35:22 2008 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_pcre.c,v 1.237 2008/08/02 04:40:44 felipe Exp $ */ +/* $Id: php_pcre.c,v 1.238 2008/08/14 14:35:22 nlopess Exp $ */ /* TODO * php_pcre_replace_impl(): @@ -1976,9 +1976,8 @@ /* Go through the input array */ zend_hash_internal_pointer_reset(Z_ARRVAL_P(input)); while(zend_hash_get_current_data(Z_ARRVAL_P(input), (void **)&entry) == SUCCESS) { - zval subject; + zval subject = **entry; - subject = **entry; if (Z_TYPE_PP(entry) != IS_STRING) { zval_copy_ctor(&subject); convert_to_string_with_converter(&subject, UG(utf8_conv)); @@ -2001,8 +2000,8 @@ } /* If the entry fits our requirements */ - if ((count > 0 && !invert) || - (count == PCRE_ERROR_NOMATCH && invert)) { + if ((count > 0 && !invert) || (count == PCRE_ERROR_NOMATCH && invert)) { + Z_ADDREF_PP(entry); /* Add to return array */ http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/tests/bug44925.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/pcre/tests/bug44925.phpt diff -u /dev/null php-src/ext/pcre/tests/bug44925.phpt:1.2 --- /dev/null Thu Aug 14 14:35:23 2008 +++ php-src/ext/pcre/tests/bug44925.phpt Thu Aug 14 14:35:22 2008 @@ -0,0 +1,107 @@ +--TEST-- +Bug #44925 (preg_grep() modifies input array) +--FILE-- +<?php +$str1 = 'a'; +$str2 = 'b'; + +$array=Array("1",2,3,1.1,FALSE,NULL,Array(), $str1, &$str2); + +var_dump($array); + +var_dump(preg_grep('/do not match/',$array)); + +$a = preg_grep('/./',$array); +var_dump($a); + +$str1 = 'x'; +$str2 = 'y'; + +var_dump($a); // check if array is still ok + +var_dump($array); + +?> +--EXPECTF-- +array(9) { + [0]=> + unicode(1) "1" + [1]=> + int(2) + [2]=> + int(3) + [3]=> + float(1.1) + [4]=> + bool(false) + [5]=> + NULL + [6]=> + array(0) { + } + [7]=> + unicode(1) "a" + [8]=> + &unicode(1) "b" +} + +Notice: Array to string conversion in %sbug44925.php on line 9 +array(0) { +} + +Notice: Array to string conversion in %sbug44925.php on line 11 +array(7) { + [0]=> + unicode(1) "1" + [1]=> + int(2) + [2]=> + int(3) + [3]=> + float(1.1) + [6]=> + array(0) { + } + [7]=> + unicode(1) "a" + [8]=> + &unicode(1) "b" +} +array(7) { + [0]=> + unicode(1) "1" + [1]=> + int(2) + [2]=> + int(3) + [3]=> + float(1.1) + [6]=> + array(0) { + } + [7]=> + unicode(1) "a" + [8]=> + &unicode(1) "y" +} +array(9) { + [0]=> + unicode(1) "1" + [1]=> + int(2) + [2]=> + int(3) + [3]=> + float(1.1) + [4]=> + bool(false) + [5]=> + NULL + [6]=> + array(0) { + } + [7]=> + unicode(1) "a" + [8]=> + &unicode(1) "y" +}
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php