From 3696e038e5e52cb231b5f0004c53cafed04f90c7 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 27 Feb 2014 16:07:36 +0400 Subject: [PATCH] Various fixes related to read_property(), read_dimension() and iterators refactoring --- Zend/zend_builtin_functions.c | 2 +- Zend/zend_closures.c | 2 +- Zend/zend_execute_API.c | 2 +- Zend/zend_generators.c | 2 +- ext/spl/spl_array.c | 14 ++++++++------ ext/spl/spl_fixedarray.c | 2 +- ext/spl/spl_iterators.c | 2 +- ext/standard/incomplete_class.c | 2 +- 8 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 3add55afe6..20477af906 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1781,7 +1781,7 @@ ZEND_FUNCTION(create_function) } new_function = emalloc(sizeof(zend_op_array)); memcpy(new_function, func, sizeof(zend_op_array)); - function_add_ref(new_function); + function_add_ref((zend_function*)new_function); function_name = STR_ALLOC(sizeof("0lambda_")+MAX_LENGTH_OF_LONG, 0); function_name->val[0] = '\0'; diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 839a3ad41b..46894c6106 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -180,7 +180,7 @@ static zend_function *zend_closure_get_method(zval *object_ptr, zend_string *met } /* }}} */ -static zval *zend_closure_read_property(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC) /* {{{ */ +static zval *zend_closure_read_property(zval *object, zval *member, int type, const zend_literal *key, zval *rv TSRMLS_DC) /* {{{ */ { ZEND_CLOSURE_PROPERTY_ERROR(); return &EG(uninitialized_zval); diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index c8679625c1..e81339b138 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -477,7 +477,7 @@ ZEND_API int zval_update_constant_ex(zval *p, void *arg, zend_class_entry *scope zend_error(E_ERROR, "Cannot declare self-referencing constant '%s'", Z_STRVAL_P(p)); } else if ((Z_TYPE_P(p) & IS_CONSTANT_TYPE_MASK) == IS_CONSTANT) { int refcount; - zend_uchar is_ref; +//??? zend_uchar is_ref; SEPARATE_ZVAL_IF_NOT_REF(p); diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index 7fb12c3cc2..7bdebf6a7b 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -671,7 +671,7 @@ zend_object_iterator *zend_generator_get_iterator(zend_class_entry *ce, zval *ob iterator = &generator->iterator; - zend_iterator_init(&iterator TSRMLS_CC); + zend_iterator_init(iterator TSRMLS_CC); iterator->funcs = &zend_generator_iterator_functions; ZVAL_COPY(&iterator->data, object); diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index ece2090a56..6564e0832b 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -371,7 +371,7 @@ fetch_dim_string: } } /* }}} */ -static zval *spl_array_read_dimension_ex(int check_inherited, zval *object, zval *offset, int type TSRMLS_DC) /* {{{ */ +static zval *spl_array_read_dimension_ex(int check_inherited, zval *object, zval *offset, int type, zval *zv TSRMLS_DC) /* {{{ */ { zval *ret; @@ -411,9 +411,9 @@ static zval *spl_array_read_dimension_ex(int check_inherited, zval *object, zval */ } /* }}} */ -static zval *spl_array_read_dimension(zval *object, zval *offset, int type TSRMLS_DC) /* {{{ */ +static zval *spl_array_read_dimension(zval *object, zval *offset, int type, zval *rv TSRMLS_DC) /* {{{ */ { - return spl_array_read_dimension_ex(1, object, offset, type TSRMLS_CC); + return spl_array_read_dimension_ex(1, object, offset, type, rv TSRMLS_CC); } /* }}} */ static void spl_array_write_dimension_ex(int check_inherited, zval *object, zval *offset, zval *value TSRMLS_DC) /* {{{ */ @@ -690,8 +690,10 @@ SPL_METHOD(Array, offsetGet) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &index) == FAILURE) { return; } - value = spl_array_read_dimension_ex(0, getThis(), index, BP_VAR_R TSRMLS_CC); - RETURN_ZVAL(value, 1, 0); + value = spl_array_read_dimension_ex(0, getThis(), index, BP_VAR_R, return_value TSRMLS_CC); + if (value != return_value) { + RETURN_ZVAL(value, 1, 0); + } } /* }}} */ /* {{{ proto void ArrayObject::offsetSet(mixed $index, mixed $newval) @@ -826,7 +828,7 @@ static zval *spl_array_read_property(zval *object, zval *member, int type, const if ((intern->ar_flags & SPL_ARRAY_ARRAY_AS_PROPS) != 0 && !std_object_handlers.has_property(object, member, 2, key TSRMLS_CC)) { - return spl_array_read_dimension(object, member, type TSRMLS_CC); + return spl_array_read_dimension(object, member, type, rv TSRMLS_CC); } return std_object_handlers.read_property(object, member, type, key, rv TSRMLS_CC); } /* }}} */ diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c index acff4964f2..5d419898be 100644 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@ -350,7 +350,7 @@ static inline zval *spl_fixedarray_object_read_dimension_helper(spl_fixedarray_o } /* }}} */ -static zval *spl_fixedarray_object_read_dimension(zval *object, zval *offset, int type TSRMLS_DC) /* {{{ */ +static zval *spl_fixedarray_object_read_dimension(zval *object, zval *offset, int type, zval *rv TSRMLS_DC) /* {{{ */ { spl_fixedarray_object *intern; diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index b30dd4ed5e..5a621bab09 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -2572,7 +2572,7 @@ static inline void spl_caching_it_next(spl_dual_it_object *intern TSRMLS_DC) } } else { if (zend_is_true(&retval TSRMLS_CC)) { - zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "getchildren", &zchildren); + zend_call_method_with_0_params(intern->inner.zobject, intern->inner.ce, NULL, "getchildren", &zchildren); if (EG(exception)) { zval_ptr_dtor(&zchildren); if (intern->u.caching.flags & CIT_CATCH_GET_CHILD) { diff --git a/ext/standard/incomplete_class.c b/ext/standard/incomplete_class.c index 3cbe70479d..fc82eb8923 100644 --- a/ext/standard/incomplete_class.c +++ b/ext/standard/incomplete_class.c @@ -49,7 +49,7 @@ static void incomplete_class_message(zval *object, int error_type TSRMLS_DC) } /* }}} */ -static zval *incomplete_class_get_property(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC) /* {{{ */ +static zval *incomplete_class_get_property(zval *object, zval *member, int type, const zend_literal *key, zval *rv TSRMLS_DC) /* {{{ */ { incomplete_class_message(object, E_NOTICE TSRMLS_CC); -- 2.40.0