mirror of
https://github.com/php/php-src.git
synced 2025-08-17 22:48:57 +02:00
Merge branch 'PHP-5.3' into PHP-5.4
Conflicts: ext/spl/spl_fixedarray.c
This commit is contained in:
commit
d24ac6953e
3 changed files with 45 additions and 10 deletions
1
NEWS
1
NEWS
|
@ -24,6 +24,7 @@ PHP NEWS
|
|||
(Johannes)
|
||||
|
||||
- SPL:
|
||||
. Fixed bug #64264 (SPLFixedArray toArray problem). (Laruence)
|
||||
. Fixed bug #64228 (RecursiveDirectoryIterator always assumes SKIP_DOTS).
|
||||
(patch by kriss@krizalys.com, Laruence)
|
||||
. Fixed bug #64106 (Segfault on SplFixedArray[][x] = y when extended).
|
||||
|
|
|
@ -627,22 +627,27 @@ SPL_METHOD(SplFixedArray, count)
|
|||
*/
|
||||
SPL_METHOD(SplFixedArray, toArray)
|
||||
{
|
||||
zval *ret, *tmp;
|
||||
HashTable *ret_ht, *obj_ht;
|
||||
spl_fixedarray_object *intern;
|
||||
|
||||
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "")) {
|
||||
return;
|
||||
}
|
||||
|
||||
ALLOC_HASHTABLE(ret_ht);
|
||||
zend_hash_init(ret_ht, 0, NULL, ZVAL_PTR_DTOR, 0);
|
||||
ALLOC_INIT_ZVAL(ret);
|
||||
Z_TYPE_P(ret) = IS_ARRAY;
|
||||
obj_ht = spl_fixedarray_object_get_properties(getThis() TSRMLS_CC);
|
||||
zend_hash_copy(ret_ht, obj_ht, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
|
||||
Z_ARRVAL_P(ret) = ret_ht;
|
||||
intern = (spl_fixedarray_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
|
||||
|
||||
RETURN_ZVAL(ret, 1, 1);
|
||||
array_init(return_value);
|
||||
if (intern->array) {
|
||||
int i = 0;
|
||||
for (; i < intern->array->size; i++) {
|
||||
if (intern->array->elements[i]) {
|
||||
zend_hash_index_update(Z_ARRVAL_P(return_value), i, (void *)&intern->array->elements[i], sizeof(zval *), NULL);
|
||||
Z_ADDREF_P(intern->array->elements[i]);
|
||||
} else {
|
||||
zend_hash_index_update(Z_ARRVAL_P(return_value), i, (void *)&EG(uninitialized_zval_ptr), sizeof(zval *), NULL);
|
||||
Z_ADDREF_P(EG(uninitialized_zval_ptr));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
29
ext/spl/tests/bug64264.phpt
Normal file
29
ext/spl/tests/bug64264.phpt
Normal file
|
@ -0,0 +1,29 @@
|
|||
--TEST--
|
||||
Bug #64264 (SPLFixedArray toArray problem)
|
||||
--FILE--
|
||||
<?php
|
||||
class MyFixedArray extends \SplFixedArray {
|
||||
protected $foo;
|
||||
protected $bar;
|
||||
}
|
||||
|
||||
$myFixedArr = new MyFixedArray(1);
|
||||
$myFixedArr[0] = 'foo';
|
||||
$myFixedArr->setSize(2);
|
||||
$myFixedArr[1] = 'bar';
|
||||
$myFixedArr->setSize(5);
|
||||
$array = $myFixedArr->toArray();
|
||||
$array[2] = "ERROR";
|
||||
$array[3] = "ERROR";
|
||||
$array[4] = "ERROR";
|
||||
unset($array[4]);
|
||||
$myFixedArr->setSize(2);
|
||||
|
||||
print_r($myFixedArr->toArray());
|
||||
?>
|
||||
--EXPECTF--
|
||||
Array
|
||||
(
|
||||
[0] => foo
|
||||
[1] => bar
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue