Fixed bug #24198 (Invalid recursion detection in array_merge_recurcive())

This commit is contained in:
Ilia Alshanetsky 2003-06-16 17:35:16 +00:00
parent 1a290fb692
commit 6057160dbf
2 changed files with 26 additions and 1 deletions

View File

@ -2141,7 +2141,7 @@ PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive TSRMLS
case HASH_KEY_IS_STRING:
if (recursive &&
zend_hash_find(dest, string_key, string_key_len, (void **)&dest_entry) == SUCCESS) {
if (*src_entry == *dest_entry) {
if (*src_entry == *dest_entry && ((*dest_entry)->refcount % 2)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "recursion detected");
return 0;
}

View File

@ -0,0 +1,25 @@
--TEST--n
Bug #24198 (array_merge_recursive() invalid recursion detection)
--FILE--
<?php
$c = array('a' => 'aa','b' => 'bb');
var_dump(array_merge_recursive($c, $c));
?>
--EXPECT--
array(2) {
["a"]=>
array(2) {
[0]=>
string(2) "aa"
[1]=>
string(2) "aa"
}
["b"]=>
array(2) {
[0]=>
string(2) "bb"
[1]=>
string(2) "bb"
}
}