summaryrefslogtreecommitdiff
path: root/ext/spl/spl_fixedarray.c
diff options
context:
space:
mode:
authorXinchen Hui <laruence@php.net>2013-02-24 12:55:46 +0800
committerXinchen Hui <laruence@php.net>2013-02-24 12:55:53 +0800
commit1b58bd39a637e9ec4ea9e95903b74aefdbd1b596 (patch)
tree88a8623346e0e2f04836fc5834f7266f968fd97f /ext/spl/spl_fixedarray.c
parentfcd4b5335a6df4e0676ee32e2267ca71d70fe623 (diff)
downloadphp-git-1b58bd39a637e9ec4ea9e95903b74aefdbd1b596.tar.gz
Fixed bug #64264 (SPLFixedArray toArray problem)
Diffstat (limited to 'ext/spl/spl_fixedarray.c')
-rw-r--r--ext/spl/spl_fixedarray.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c
index 1d18afd04a..646c002f6f 100644
--- a/ext/spl/spl_fixedarray.c
+++ b/ext/spl/spl_fixedarray.c
@@ -611,8 +611,6 @@ SPL_METHOD(SplFixedArray, count)
SPL_METHOD(SplFixedArray, toArray)
{
spl_fixedarray_object *intern;
- zval *ret, *tmp;
- HashTable *ret_ht, *obj_ht;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "")) {
return;
@@ -620,15 +618,19 @@ SPL_METHOD(SplFixedArray, toArray)
intern = (spl_fixedarray_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
- 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;
-
- 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));
+ }
+ }
+ }
}
/* }}} */