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;
}
--- /dev/null
+--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"
+ }
+}