diff options
author | Dmitry Stogov <dmitry@php.net> | 2008-11-27 19:01:23 +0000 |
---|---|---|
committer | Dmitry Stogov <dmitry@php.net> | 2008-11-27 19:01:23 +0000 |
commit | 7d4fd3fd380a7fe9b497684775a38190786b93ba (patch) | |
tree | 0ff7829b47dc4969052284b9ad9411c465bd424e /Zend/zend_API.c | |
parent | d741138a4639adb14cb31ea519ded0e0432c9e9a (diff) | |
download | php-git-7d4fd3fd380a7fe9b497684775a38190786b93ba.tar.gz |
Fixed bug #46409 (__invoke method called outside of object context when using array_map)
Diffstat (limited to 'Zend/zend_API.c')
-rw-r--r-- | Zend/zend_API.c | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 324902d0fb..59ea7ab2bc 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -2329,8 +2329,8 @@ static int zend_is_callable_check_class(const char *name, int name_len, zend_fca } else { fcc->called_scope = EG(called_scope); fcc->calling_scope = EG(scope); - if (!fcc->object_pp) { - fcc->object_pp = EG(This) ? &EG(This) : NULL; + if (!fcc->object_ptr) { + fcc->object_ptr = EG(This); } ret = 1; } @@ -2343,8 +2343,8 @@ static int zend_is_callable_check_class(const char *name, int name_len, zend_fca } else { fcc->called_scope = EG(called_scope); fcc->calling_scope = EG(scope)->parent; - if (!fcc->object_pp) { - fcc->object_pp = EG(This) ? &EG(This) : NULL; + if (!fcc->object_ptr) { + fcc->object_ptr = EG(This); } ret = 1; } @@ -2355,8 +2355,8 @@ static int zend_is_callable_check_class(const char *name, int name_len, zend_fca } else { fcc->called_scope = EG(called_scope); fcc->calling_scope = EG(called_scope); - if (!fcc->object_pp) { - fcc->object_pp = EG(This) ? &EG(This) : NULL; + if (!fcc->object_ptr) { + fcc->object_ptr = EG(This); } ret = 1; } @@ -2364,13 +2364,13 @@ static int zend_is_callable_check_class(const char *name, int name_len, zend_fca zend_class_entry *scope = EG(active_op_array) ? EG(active_op_array)->scope : NULL; fcc->calling_scope = *pce; - if (scope && !fcc->object_pp && EG(This) && + if (scope && !fcc->object_ptr && EG(This) && instanceof_function(Z_OBJCE_P(EG(This)), scope TSRMLS_CC) && instanceof_function(scope, fcc->calling_scope TSRMLS_CC)) { - fcc->object_pp = &EG(This); - fcc->called_scope = Z_OBJCE_PP(fcc->object_pp); + fcc->object_ptr = EG(This); + fcc->called_scope = Z_OBJCE_P(fcc->object_ptr); } else { - fcc->called_scope = fcc->object_pp ? Z_OBJCE_PP(fcc->object_pp) : fcc->calling_scope; + fcc->called_scope = fcc->object_ptr ? Z_OBJCE_P(fcc->object_ptr) : fcc->calling_scope; } ret = 1; } else { @@ -2480,9 +2480,9 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca fcc->function_handler = priv_fbc; } } - } else if (fcc->object_pp) { - if (Z_OBJ_HT_PP(fcc->object_pp)->get_method) { - fcc->function_handler = Z_OBJ_HT_PP(fcc->object_pp)->get_method(fcc->object_pp, mname, mlen TSRMLS_CC); + } else if (fcc->object_ptr) { + if (Z_OBJ_HT_P(fcc->object_ptr)->get_method) { + fcc->function_handler = Z_OBJ_HT_P(fcc->object_ptr)->get_method(&fcc->object_ptr, mname, mlen TSRMLS_CC); retval = fcc->function_handler ? 1 : 0; call_via_handler = 1; } @@ -2498,7 +2498,7 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca if (retval) { if (fcc->calling_scope && !call_via_handler) { - if (!fcc->object_pp && !(fcc->function_handler->common.fn_flags & ZEND_ACC_STATIC)) { + if (!fcc->object_ptr && !(fcc->function_handler->common.fn_flags & ZEND_ACC_STATIC)) { int severity; char *verb; if (fcc->function_handler->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { @@ -2513,7 +2513,7 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca retval = 0; } if (EG(This) && instanceof_function(Z_OBJCE_P(EG(This)), fcc->calling_scope TSRMLS_CC)) { - fcc->object_pp = &EG(This); + fcc->object_ptr = EG(This); if (error) { zend_spprintf(error, 0, "non-static method %s::%s() %s be called statically, assuming $this from compatible context %s", fcc->calling_scope->name, fcc->function_handler->common.function_name, verb, Z_OBJCE_P(EG(This))->name); } else if (retval) { @@ -2529,7 +2529,7 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca } if (retval && (check_flags & IS_CALLABLE_CHECK_NO_ACCESS) == 0) { if (fcc->function_handler->op_array.fn_flags & ZEND_ACC_PRIVATE) { - if (!zend_check_private(fcc->function_handler, fcc->object_pp ? Z_OBJCE_PP(fcc->object_pp) : EG(scope), lmname, mlen TSRMLS_CC)) { + if (!zend_check_private(fcc->function_handler, fcc->object_ptr ? Z_OBJCE_P(fcc->object_ptr) : EG(scope), lmname, mlen TSRMLS_CC)) { if (error) { if (*error) { efree(*error); @@ -2560,8 +2560,8 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca } efree(lmname); - if (fcc->object_pp) { - fcc->called_scope = Z_OBJCE_PP(fcc->object_pp); + if (fcc->object_ptr) { + fcc->called_scope = Z_OBJCE_P(fcc->object_ptr); } if (retval) { fcc->initialized = 1; @@ -2570,7 +2570,7 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca } /* }}} */ -ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval **object_pp, uint check_flags, char **callable_name, int *callable_name_len, zend_fcall_info_cache *fcc, char **error TSRMLS_DC) /* {{{ */ +ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval *object_ptr, uint check_flags, char **callable_name, int *callable_name_len, zend_fcall_info_cache *fcc, char **error TSRMLS_DC) /* {{{ */ { zend_bool ret; int callable_name_len_local; @@ -2594,22 +2594,22 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval **object_pp, uint ch fcc->called_scope = NULL; fcc->function_handler = NULL; fcc->calling_scope = NULL; - fcc->object_pp = NULL; + fcc->object_ptr = NULL; - if (object_pp && (!*object_pp || Z_TYPE_PP(object_pp) != IS_OBJECT)) { - object_pp = NULL; + if (object_ptr && Z_TYPE_P(object_ptr) != IS_OBJECT) { + object_ptr = NULL; } - if (object_pp && + if (object_ptr && (!EG(objects_store).object_buckets || - !EG(objects_store).object_buckets[Z_OBJ_HANDLE_PP(object_pp)].valid)) { + !EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(object_ptr)].valid)) { return 0; } switch (Z_TYPE_P(callable)) { case IS_STRING: - if (object_pp && *object_pp) { - fcc->object_pp = object_pp; - fcc->calling_scope = Z_OBJCE_PP(object_pp); + if (object_ptr) { + fcc->object_ptr = object_ptr; + fcc->calling_scope = Z_OBJCE_P(object_ptr); if (callable_name) { char *ptr; @@ -2687,7 +2687,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval **object_pp, uint ch fcc->calling_scope = Z_OBJCE_PP(obj); /* TBFixed: what if it's overloaded? */ - fcc->object_pp = obj; + fcc->object_ptr = *obj; if (callable_name) { char *ptr; @@ -2740,7 +2740,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval **object_pp, uint ch return 0; case IS_OBJECT: - if (Z_OBJ_HANDLER_P(callable, get_closure) && Z_OBJ_HANDLER_P(callable, get_closure)(callable, &fcc->calling_scope, &fcc->function_handler, NULL, &fcc->object_pp TSRMLS_CC) == SUCCESS) { + if (Z_OBJ_HANDLER_P(callable, get_closure) && Z_OBJ_HANDLER_P(callable, get_closure)(callable, &fcc->calling_scope, &fcc->function_handler, &fcc->object_ptr TSRMLS_CC) == SUCCESS) { fcc->called_scope = fcc->calling_scope; if (callable_name) { zend_class_entry *ce = Z_OBJCE_P(callable); /* TBFixed: what if it's overloaded? */ @@ -2811,7 +2811,7 @@ ZEND_API int zend_fcall_info_init(zval *callable, uint check_flags, zend_fcall_i fci->size = sizeof(*fci); fci->function_table = fcc->calling_scope ? &fcc->calling_scope->function_table : EG(function_table); - fci->object_pp = fcc->object_pp; + fci->object_ptr = fcc->object_ptr; fci->function_name = callable; fci->retval_ptr_ptr = NULL; fci->param_count = 0; |