Index: ext/standard/array.c =================================================================== RCS file: /repository/php-src/ext/standard/array.c,v retrieving revision 1.199.2.21 diff -u -r1.199.2.21 array.c --- ext/standard/array.c 17 Jun 2003 13:20:18 -0000 1.199.2.21 +++ ext/standard/array.c 1 Oct 2003 14:26:53 -0000 @@ -1987,6 +1987,8 @@ PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive TSRMLS_DC) { + int ret; + zval *src_copy; zval **src_entry, **dest_entry; char *string_key; @@ -2006,12 +2008,24 @@ get_active_function_name(TSRMLS_C)); return 0; } - SEPARATE_ZVAL(dest_entry); + ALLOC_ZVAL(src_copy); + *src_copy = **src_entry; + zval_copy_ctor(*src_entry); + src_copy->refcount = 1; + src_copy->is_ref = 0; + convert_to_array_ex(&src_copy); + + SEPARATE_ZVAL(dest_entry); convert_to_array_ex(dest_entry); - convert_to_array_ex(src_entry); - if (!php_array_merge(Z_ARRVAL_PP(dest_entry), - Z_ARRVAL_PP(src_entry), recursive TSRMLS_CC)) - return 0; + + ret = (php_array_merge(Z_ARRVAL_PP(dest_entry), + Z_ARRVAL_P(src_copy), recursive TSRMLS_CC)); + + zval_dtor(src_copy); + + if(!ret) { + return 0; + } } else { (*src_entry)->refcount++;