From: Felipe Pena Date: Wed, 27 Feb 2008 02:04:09 +0000 (+0000) Subject: MFB: Fixed bug #43559 (array_merge_recursive() doesn't behave as expected with duplic... X-Git-Tag: php-5.2.6RC1~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5db9cbbc405b8b8f79f4890b6a414f4a98f5b07b;p=php MFB: Fixed bug #43559 (array_merge_recursive() doesn't behave as expected with duplicate NULL values) --- diff --git a/NEWS b/NEWS index 4968482b7b..3305e03bd3 100644 --- a/NEWS +++ b/NEWS @@ -79,6 +79,8 @@ PHP NEWS - Fixed bug #43589 (a possible infinite loop in bz2_filter.c). (Greg) - Fixed bug #43580 (removed bogus declaration of a non-existent php_is_url() function). (Ilia) +- Fixed bug #43559 (array_merge_recursive() doesn't behave as expected with + duplicate NULL values). (Felipe, Tony) - Fixed bug #43533 (escapeshellarg('') returns null). (Ilia) - Fixed bug #43527 (DateTime created from a timestamp reports environment timezone). (Derick) diff --git a/ext/standard/array.c b/ext/standard/array.c index 98666f3cfa..2dbfa0e035 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -2312,8 +2312,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++; } diff --git a/ext/standard/tests/array/array_merge_recursive_variation5.phpt b/ext/standard/tests/array/array_merge_recursive_variation5.phpt index 6a6a50140f..3b251220ea 100644 --- a/ext/standard/tests/array/array_merge_recursive_variation5.phpt +++ b/ext/standard/tests/array/array_merge_recursive_variation5.phpt @@ -374,8 +374,10 @@ array(8) { object(classA)#%d (0) { } ["string"]=> - array(1) { + array(2) { [0]=> + NULL + [1]=> string(5) "hello" } ["resource"]=>