From: Dmitry Stogov Date: Wed, 10 Aug 2005 07:43:16 +0000 (+0000) Subject: Fixed bug #29253 (array_diff with $GLOBALS argument fails) X-Git-Tag: BEFORE_UNICODE_MERGE~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=655e19326df192518e3a773ff750d0b4327ab3de;p=php Fixed bug #29253 (array_diff with $GLOBALS argument fails) --- diff --git a/NEWS b/NEWS index 74e844c641..c5621c755e 100644 --- a/NEWS +++ b/NEWS @@ -49,6 +49,7 @@ PHP NEWS - Fixed bug #32139 (SOAP client does not auto-handle base64 encoding). (Ilia) - Fixed bug #32010 (Memory leak in mssql_fetch_batch). (fmk) - Fixed bug #29334 (win32 mail() provides incorrect Date: header). (Jani) +- Fixed bug #29253 (array_diff with $GLOBALS argument fails). (Dmitry) 14 Jul 2005, PHP 5.1 Beta 3 - Upgraded bundled SQLite library for PDO:SQLite to 3.2.2 (Ilia) diff --git a/ext/standard/array.c b/ext/standard/array.c index 228c8b457f..732672029e 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -3044,6 +3044,15 @@ static void php_array_intersect(INTERNAL_FUNCTION_PARAMETERS, int behavior, int /* copy the argument array */ RETVAL_ZVAL(*args[0], 1, 0); + if (return_value->value.ht == &EG(symbol_table)) { + HashTable *ht; + zval *tmp; + + ALLOC_HASHTABLE_REL(ht); + zend_hash_init(ht, 0, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_copy(ht, return_value->value.ht, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); + return_value->value.ht = ht; + } if ((behavior & INTERSECT_NORMAL) && data_compare_type == INTERSECT_COMP_DATA_USER) { /* array_uintersect() */ @@ -3420,6 +3429,15 @@ static void php_array_diff(INTERNAL_FUNCTION_PARAMETERS, int behavior, int data_ /* copy the argument array */ RETVAL_ZVAL(*args[0], 1, 0); + if (return_value->value.ht == &EG(symbol_table)) { + HashTable *ht; + zval *tmp; + + ALLOC_HASHTABLE_REL(ht); + zend_hash_init(ht, 0, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_copy(ht, return_value->value.ht, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); + return_value->value.ht = ht; + } if (behavior == DIFF_NORMAL && data_compare_type == DIFF_COMP_DATA_USER) { /* array_udiff() */ diff --git a/ext/standard/tests/array/bug29253.phpt b/ext/standard/tests/array/bug29253.phpt new file mode 100755 index 0000000000..a495d65cfc --- /dev/null +++ b/ext/standard/tests/array/bug29253.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #29253 array_diff with $GLOBALS argument fails +--FILE-- + +--EXPECT-- +array(0) { +} +string(4) "afad"