felipe          Wed Mar 12 19:21:30 2008 UTC

  Modified files:              
    /php-src/ext/standard       array.c 
    /php-src/ext/standard/tests/array   bug42177.phpt 
  Log:
  MFB: Fixed bug #42177 (Warning "array_merge_recursive(): recursion detected" 
comes again...)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.447&r2=1.448&diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.447 php-src/ext/standard/array.c:1.448
--- php-src/ext/standard/array.c:1.447  Fri Feb 22 13:48:02 2008
+++ php-src/ext/standard/array.c        Wed Mar 12 19:21:30 2008
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: array.c,v 1.447 2008/02/22 13:48:02 felipe Exp $ */
+/* $Id: array.c,v 1.448 2008/03/12 19:21:30 felipe Exp $ */
 
 #include "php.h"
 #include "php_ini.h"
@@ -2410,7 +2410,7 @@
                                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;
                                        }
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/bug42177.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/bug42177.phpt
diff -u /dev/null php-src/ext/standard/tests/array/bug42177.phpt:1.2
--- /dev/null   Wed Mar 12 19:21:30 2008
+++ php-src/ext/standard/tests/array/bug42177.phpt      Wed Mar 12 19:21:30 2008
@@ -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



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to