mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
- Fixed bug #54970 (SplFixedArray::setSize() isn't resizing)
This commit is contained in:
parent
329eae2a7a
commit
767f924665
@ -154,6 +154,8 @@ static HashTable* spl_fixedarray_object_get_properties(zval *obj TSRMLS_DC) /* {
|
||||
int i = 0;
|
||||
|
||||
if (intern->array) {
|
||||
int j = zend_hash_num_elements(ht);
|
||||
|
||||
for (i = 0; i < intern->array->size; i++) {
|
||||
if (intern->array->elements[i]) {
|
||||
zend_hash_index_update(ht, i, (void *)&intern->array->elements[i], sizeof(zval *), NULL);
|
||||
@ -166,6 +168,11 @@ static HashTable* spl_fixedarray_object_get_properties(zval *obj TSRMLS_DC) /* {
|
||||
Z_ADDREF_P(EG(uninitialized_zval_ptr));
|
||||
}
|
||||
}
|
||||
if (j > intern->array->size) {
|
||||
for (i = intern->array->size; i < j; ++i) {
|
||||
zend_hash_index_del(ht, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ht;
|
||||
|
33
ext/spl/tests/bug54970.phpt
Normal file
33
ext/spl/tests/bug54970.phpt
Normal file
@ -0,0 +1,33 @@
|
||||
--TEST--
|
||||
Bug #54970 (SplFixedArray::setSize() isn't resizing)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$fa = new SplFixedArray(2);
|
||||
$fa[0] = 'Hello';
|
||||
$fa[1] = 'World';
|
||||
$fa->setSize(3);
|
||||
$fa[2] = '!';
|
||||
var_dump($fa);
|
||||
$fa->setSize(2);
|
||||
var_dump($fa);
|
||||
var_dump($fa->getSize());
|
||||
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
object(SplFixedArray)#%d (3) {
|
||||
[0]=>
|
||||
string(5) "Hello"
|
||||
[1]=>
|
||||
string(5) "World"
|
||||
[2]=>
|
||||
string(1) "!"
|
||||
}
|
||||
object(SplFixedArray)#%d (2) {
|
||||
[0]=>
|
||||
string(5) "Hello"
|
||||
[1]=>
|
||||
string(5) "World"
|
||||
}
|
||||
int(2)
|
Loading…
Reference in New Issue
Block a user