From: Nuno Lopes Date: Thu, 14 Aug 2008 14:35:22 +0000 (+0000) Subject: sync with 5.3 branch. add test for bug #44925 X-Git-Tag: BEFORE_HEAD_NS_CHANGE~721 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bdeeaa526aea211402a19c8ccae6411b495c392e;p=php sync with 5.3 branch. add test for bug #44925 --- diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index f1ee5585c3..18a08481ac 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -1976,9 +1976,8 @@ PHPAPI void php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval *return /* 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 @@ PHPAPI void php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval *return } /* 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 */ diff --git a/ext/pcre/tests/bug44925.phpt b/ext/pcre/tests/bug44925.phpt new file mode 100644 index 0000000000..84a3314a47 --- /dev/null +++ b/ext/pcre/tests/bug44925.phpt @@ -0,0 +1,107 @@ +--TEST-- +Bug #44925 (preg_grep() modifies input array) +--FILE-- + +--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" +}