]> granicus.if.org Git - php/commitdiff
MFH: fix #43559 (array_merge_recursive() doesn't behave as expected with duplicate...
authorAntony Dovgal <tony2001@php.net>
Wed, 23 Jan 2008 12:09:52 +0000 (12:09 +0000)
committerAntony Dovgal <tony2001@php.net>
Wed, 23 Jan 2008 12:09:52 +0000 (12:09 +0000)
patch by Felipe

ext/standard/array.c
ext/standard/tests/array/array_merge_recursive_variation5.phpt

index c7f2c3a30a6b4fe13a635135dfd0435746994317..9283de508ad95ab9af75394ed3cf0025245b8604 100644 (file)
@@ -2197,8 +2197,18 @@ PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive TSRMLS
                                        SEPARATE_ZVAL(dest_entry);
                                        SEPARATE_ZVAL(src_entry);
 
-                                       convert_to_array_ex(dest_entry);
-                                       convert_to_array_ex(src_entry);
+                                       if (Z_TYPE_PP(dest_entry) == IS_NULL) {
+                                               convert_to_array_ex(dest_entry);
+                                               add_next_index_null(*dest_entry);
+                                       } else {
+                                               convert_to_array_ex(dest_entry);
+                                       }
+                                       if (Z_TYPE_PP(src_entry) == IS_NULL) {
+                                               convert_to_array_ex(src_entry);
+                                               add_next_index_null(*src_entry);
+                                       } else {
+                                               convert_to_array_ex(src_entry);
+                                       }
                                        if (thash) {
                                                thash->nApplyCount++;
                                        }
index 6a6a50140f720a75b405aebee9cddacf066a3963..3b251220ea79b9869c8da204db67495cf0f64873 100644 (file)
@@ -374,8 +374,10 @@ array(8) {
   object(classA)#%d (0) {
   }
   ["string"]=>
-  array(1) {
+  array(2) {
     [0]=>
+    NULL
+    [1]=>
     string(5) "hello"
   }
   ["resource"]=>