diff options
Diffstat (limited to 'ext/spl/spl_array.c')
-rw-r--r-- | ext/spl/spl_array.c | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index ead514d7cd..1f4cad1f15 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2015 The PHP Group | + | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -130,6 +130,10 @@ static zend_always_inline uint32_t *spl_array_get_pos_ptr(HashTable *ht, spl_arr static void spl_array_object_free_storage(zend_object *object) { spl_array_object *intern = spl_array_from_obj(object); + + if (intern->ht_iter != (uint32_t) -1) { + zend_hash_iterator_del(intern->ht_iter); + } zend_object_std_dtor(&intern->std); @@ -273,9 +277,10 @@ static zval *spl_array_get_dimension_ptr(int check_inherited, zval *object, zval if ((type == BP_VAR_W || type == BP_VAR_RW) && (ht->u.v.nApplyCount > 0)) { zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited"); - return &EG(error_zval);; + return &EG(error_zval); } +try_again: switch (Z_TYPE_P(offset)) { case IS_NULL: offset_key = ZSTR_EMPTY_ALLOC(); @@ -355,6 +360,9 @@ num_index: } } return retval; + case IS_REFERENCE: + ZVAL_DEREF(offset); + goto try_again; default: zend_error(E_WARNING, "Illegal offset type"); return (type == BP_VAR_W || type == BP_VAR_RW) ? @@ -442,6 +450,8 @@ static void spl_array_write_dimension_ex(int check_inherited, zval *object, zval if (Z_REFCOUNTED_P(value)) { Z_ADDREF_P(value); } + +try_again: switch (Z_TYPE_P(offset)) { case IS_STRING: ht = spl_array_get_hash_table(intern, 0); @@ -481,6 +491,9 @@ num_index: } zend_hash_next_index_insert(ht, value); return; + case IS_REFERENCE: + ZVAL_DEREF(offset); + goto try_again; default: zend_error(E_WARNING, "Illegal offset type"); return; @@ -505,7 +518,8 @@ static void spl_array_unset_dimension_ex(int check_inherited, zval *object, zval return; } - switch(Z_TYPE_P(offset)) { +try_again: + switch (Z_TYPE_P(offset)) { case IS_STRING: ht = spl_array_get_hash_table(intern, 0); if (ht->u.v.nApplyCount > 0) { @@ -565,6 +579,9 @@ num_index: zend_error(E_NOTICE,"Undefined offset: %pd", index); } break; + case IS_REFERENCE: + ZVAL_DEREF(offset); + goto try_again; default: zend_error(E_WARNING, "Illegal offset type"); return; @@ -603,7 +620,8 @@ static int spl_array_has_dimension_ex(int check_inherited, zval *object, zval *o if (!value) { HashTable *ht = spl_array_get_hash_table(intern, 0); - switch(Z_TYPE_P(offset)) { +try_again: + switch (Z_TYPE_P(offset)) { case IS_STRING: if ((tmp = zend_symtable_find(ht, Z_STR_P(offset))) != NULL) { if (check_empty == 2) { @@ -637,7 +655,9 @@ num_index: return 0; } break; - + case IS_REFERENCE: + ZVAL_DEREF(offset); + goto try_again; default: zend_error(E_WARNING, "Illegal offset type"); return 0; @@ -1153,8 +1173,8 @@ zend_object_iterator *spl_array_get_iterator(zend_class_entry *ce, zval *object, } /* }}} */ -/* {{{ proto void ArrayObject::__construct(array|object ar = array() [, int flags = 0 [, string iterator_class = "ArrayIterator"]]) - proto void ArrayIterator::__construct(array|object ar = array() [, int flags = 0]) +/* {{{ proto void ArrayObject::__construct([array|object ar = array() [, int flags = 0 [, string iterator_class = "ArrayIterator"]]]) + proto void ArrayIterator::__construct([array|object ar = array() [, int flags = 0]]) Constructs a new array iterator from a path. */ SPL_METHOD(Array, __construct) { @@ -1796,6 +1816,8 @@ outexcept: /* {{{ arginfo and function table */ ZEND_BEGIN_ARG_INFO_EX(arginfo_array___construct, 0, 0, 0) ZEND_ARG_INFO(0, array) + ZEND_ARG_INFO(0, ar_flags) + ZEND_ARG_INFO(0, iterator_class) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_array_offsetGet, 0, 0, 1) |