1
0
mirror of https://github.com/php/php-src.git synced 2026-04-26 01:18:19 +02:00

MFB: Fixed bug #42177 (Warning "array_merge_recursive(): recursion detected" comes again...)

This commit is contained in:
Felipe Pena
2008-03-12 19:18:42 +00:00
parent c94d9b0c12
commit eea093b47c
2 changed files with 35 additions and 1 deletions
+1 -1
View File
@@ -2210,7 +2210,7 @@ PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive TSRMLS
if (recursive && zend_hash_find(dest, string_key, string_key_len, (void **)&dest_entry) == SUCCESS) {
HashTable *thash = HASH_OF(*dest_entry);
if ((thash && thash->nApplyCount > 1) || (*src_entry == *dest_entry && (Z_REFCOUNT_PP(dest_entry) % 2))) {
if ((thash && thash->nApplyCount > 1) || (*src_entry == *dest_entry && Z_ISREF_PP(dest_entry) && (Z_REFCOUNT_PP(dest_entry) % 2))) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "recursion detected");
return 0;
}
+34
View File
@@ -0,0 +1,34 @@
--TEST--
Bug #42177 (Warning "array_merge_recursive(): recursion detected" comes again...)
--FILE--
<?php
$a1 = array( 'key1' => 1, 'key3' => 2 );
$a2 = array();
$a1 = array_merge_recursive( $a1, $a2 );
$a1 = array_merge_recursive( $a1, $a2 );
unset( $a1, $a2 );
$a1 = array();
$a2 = array( 'key1' => 1, 'key3' => 2 );
$a1 = array_merge_recursive( $a1, $a2 );
$a1 = array_merge_recursive( $a1, $a2 );
unset( $a1, $a2 );
$a1 = array();
$a2 = array( 'key1' => &$a1 );
$a1 = array_merge_recursive( $a1, $a2 );
$a1 = array_merge_recursive( $a1, $a2 );
unset( $a1, $a2 );
$x = 'foo';
$y =& $x;
$a1 = array($x, $y, $x, $y);
$a2 = array( 'key1' => $a1, $x, $y );
$a1 = array_merge_recursive( $a1, $a2 );
$a1 = array_merge_recursive( $a1, $a2 );
unset( $a1, $a2 );
?>
--EXPECTF--
Warning: array_merge_recursive(): recursion detected in %s on line 18