diff options
author | Felipe Pena <felipe@php.net> | 2008-03-12 19:21:30 +0000 |
---|---|---|
committer | Felipe Pena <felipe@php.net> | 2008-03-12 19:21:30 +0000 |
commit | 8ae1faf51796d7e0524f65f71ab89ce8a77048d0 (patch) | |
tree | 1a84aa7b1b2267cbfaf543b2348e5a201d2d132b /ext | |
parent | 32ed6f39de70123239d6c262bf547f240a83f678 (diff) | |
download | php-git-8ae1faf51796d7e0524f65f71ab89ce8a77048d0.tar.gz |
MFB: Fixed bug #42177 (Warning "array_merge_recursive(): recursion detected" comes again...)
Diffstat (limited to 'ext')
-rw-r--r-- | ext/standard/array.c | 2 | ||||
-rw-r--r-- | ext/standard/tests/array/bug42177.phpt | 34 |
2 files changed, 35 insertions, 1 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c index 4174608a2c..1a4e9d4f41 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -2410,7 +2410,7 @@ ukey: if (recursive && zend_u_hash_find(dest, utype, 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; } diff --git a/ext/standard/tests/array/bug42177.phpt b/ext/standard/tests/array/bug42177.phpt new file mode 100644 index 0000000000..5678ca3cac --- /dev/null +++ b/ext/standard/tests/array/bug42177.phpt @@ -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 |