PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? Jan 2007, PHP 5.2.1RC4
+- Fixed bug #40191 (use of array_unique() with objects triggers segfault).
+ (Tony)
- Fixed bug #40169 (CURLOPT_TCP_NODELAY only available in curl >= 7.11.2).
(Tony)
- Fixed bug #39450 (getenv() fills other super-globals). (Ilia, Tony)
Removes duplicate values from array */
PHP_FUNCTION(array_unique)
{
- zval **array;
+ zval **array, *tmp;
HashTable *target_hash;
Bucket *p;
struct bucketindex {
RETURN_FALSE;
}
- /* copy the argument array */
- RETVAL_ZVAL(*array, 1, 0);
+ array_init(return_value);
+ zend_hash_copy(Z_ARRVAL_P(return_value), target_hash, (copy_ctor_func_t) zval_add_ref, (void *)&tmp, sizeof(zval*));
if (target_hash->nNumOfElements <= 1) { /* nothing to do */
return;
--- /dev/null
+--TEST--
+Bug #40191 (use of array_unique() with objects triggers segfault)
+--FILE--
+<?php
+
+$arrObj = new ArrayObject();
+$arrObj->append('foo');
+$arrObj->append('bar');
+$arrObj->append('foo');
+
+$arr = array_unique($arrObj);
+var_dump($arr);
+
+echo "Done\n";
+?>
+--EXPECTF--
+array(2) {
+ [0]=>
+ string(3) "foo"
+ [1]=>
+ string(3) "bar"
+}
+Done