Skip to content

Commit

Permalink
Fixed bug #29253 (array_diff with $GLOBALS argument fails)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Aug 10, 2005
1 parent f0f1557 commit 96d7559
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,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)
Expand Down
18 changes: 18 additions & 0 deletions ext/standard/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(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() */
Expand Down Expand Up @@ -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(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() */
Expand Down
13 changes: 13 additions & 0 deletions ext/standard/tests/array/bug29253.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Bug #29253 array_diff with $GLOBALS argument fails
--FILE--
<?php
$zz = $GLOBALS;
$gg = 'afad';
var_dump(array_diff_assoc($GLOBALS, $zz));
var_dump($gg);
?>
--EXPECT--
array(0) {
}
string(4) "afad"

0 comments on commit 96d7559

Please sign in to comment.