summaryrefslogtreecommitdiff
path: root/ext/spl/spl_array.c
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2015-12-04 06:45:26 -0800
committerXinchen Hui <laruence@gmail.com>2015-12-04 06:45:26 -0800
commit7ac24aa661b9bc9983bb92a734e2c9993db147c5 (patch)
tree004cfb172fe9b3f8e81f227f83f520629037cb2d /ext/spl/spl_array.c
parent3ae3341533b68cccaccfc0d78456b72d004dfc80 (diff)
downloadphp-git-7ac24aa661b9bc9983bb92a734e2c9993db147c5.tar.gz
Fixed bug #71028 (Undefined index with ArrayIterator)
Diffstat (limited to 'ext/spl/spl_array.c')
-rw-r--r--ext/spl/spl_array.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index ead514d7cd..da572f09b9 100644
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -276,6 +276,7 @@ static zval *spl_array_get_dimension_ptr(int check_inherited, zval *object, zval
return &EG(error_zval);;
}
+try_again:
switch (Z_TYPE_P(offset)) {
case IS_NULL:
offset_key = ZSTR_EMPTY_ALLOC();
@@ -355,6 +356,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 +446,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 +487,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;
@@ -603,7 +612,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 +647,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;