summaryrefslogtreecommitdiff
path: root/ext/spl/spl_array.c
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2016-03-20 18:17:44 +0100
committerNikita Popov <nikic@php.net>2016-03-20 18:17:44 +0100
commitf3309173f916e3c5cf37910975f04310706336b5 (patch)
tree5e4be39f65137cfc426e91e7c4f18ce66d75acb2 /ext/spl/spl_array.c
parent12f2665df829eac53e2036e335b40cf391ff8652 (diff)
downloadphp-git-f3309173f916e3c5cf37910975f04310706336b5.tar.gz
Fixed bug #62059
Diffstat (limited to 'ext/spl/spl_array.c')
-rw-r--r--ext/spl/spl_array.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index 685dd27092..d5cb32606e 100644
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -275,12 +275,11 @@ static zend_object *spl_array_object_clone(zval *zobject)
}
/* }}} */
-static zval *spl_array_get_dimension_ptr(int check_inherited, zval *object, zval *offset, int type) /* {{{ */
+static zval *spl_array_get_dimension_ptr(int check_inherited, spl_array_object *intern, zval *offset, int type) /* {{{ */
{
zval *retval;
zend_long index;
zend_string *offset_key;
- spl_array_object *intern = Z_SPLARRAY_P(object);
HashTable *ht = spl_array_get_hash_table(intern);
if (!offset || Z_ISUNDEF_P(offset)) {
@@ -382,12 +381,21 @@ num_index:
}
} /* }}} */
+static int spl_array_has_dimension(zval *object, zval *offset, int check_empty);
+
static zval *spl_array_read_dimension_ex(int check_inherited, zval *object, zval *offset, int type, zval *rv) /* {{{ */
{
+ spl_array_object *intern = Z_SPLARRAY_P(object);
zval *ret;
- if (check_inherited) {
- spl_array_object *intern = Z_SPLARRAY_P(object);
+ if (check_inherited &&
+ (intern->fptr_offset_get || (type == BP_VAR_IS && intern->fptr_offset_has))) {
+ if (type == BP_VAR_IS) {
+ if (!spl_array_has_dimension(object, offset, 0)) {
+ return &EG(uninitialized_zval);
+ }
+ }
+
if (intern->fptr_offset_get) {
zval tmp;
if (!offset) {
@@ -405,7 +413,8 @@ static zval *spl_array_read_dimension_ex(int check_inherited, zval *object, zval
return &EG(uninitialized_zval);
}
}
- ret = spl_array_get_dimension_ptr(check_inherited, object, offset, type);
+
+ ret = spl_array_get_dimension_ptr(check_inherited, intern, offset, type);
/* When in a write context,
* ZE has to be fooled into thinking this is in a reference set
@@ -879,7 +888,7 @@ static zval *spl_array_get_property_ptr_ptr(zval *object, zval *member, int type
if ((intern->ar_flags & SPL_ARRAY_ARRAY_AS_PROPS) != 0
&& !std_object_handlers.has_property(object, member, 2, NULL)) {
- return spl_array_get_dimension_ptr(1, object, member, type);
+ return spl_array_get_dimension_ptr(1, intern, member, type);
}
return std_object_handlers.get_property_ptr_ptr(object, member, type, cache_slot);
} /* }}} */