diff options
author | Nikita Popov <nikic@php.net> | 2016-08-06 15:24:23 +0200 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2016-08-23 10:29:15 +0300 |
commit | 906456c4106ac74da0688b2481e91e27de3b176b (patch) | |
tree | 2f63f965aa2d372339999f7a5a1973161348e0f4 /Zend/zend_execute_API.c | |
parent | 26d74a0420d7b915c701b0a6afc2a90b5ac5782f (diff) | |
download | php-git-906456c4106ac74da0688b2481e91e27de3b176b.tar.gz |
call_user_func(_array): Don't abort on reference warning
Change zend_call_function() to not abort the call if a non-reference
is passed to a reference argument. The usual warning will still be
thrown, but the call will proceed as usual.
Diffstat (limited to 'Zend/zend_execute_API.c')
-rw-r--r-- | Zend/zend_execute_API.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 3432064eaf..dc411af835 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -788,41 +788,29 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / if (ARG_SHOULD_BE_SENT_BY_REF(func, i + 1)) { if (UNEXPECTED(!Z_ISREF_P(arg))) { - if (fci->no_separation && - !ARG_MAY_BE_SENT_BY_REF(func, i + 1)) { - if (i) { - /* hack to clean up the stack */ - ZEND_CALL_NUM_ARGS(call) = i; - zend_vm_stack_free_args(call); - } - zend_vm_stack_free_call_frame(call); - - zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given", - i+1, + if (!fci->no_separation) { + /* Separation is enabled -- create a ref */ + ZVAL_NEW_REF(arg, arg); + } else if (!ARG_MAY_BE_SENT_BY_REF(func, i + 1)) { + /* By-value send is not allowed -- emit a warning, + * but still perform the call with a by-value send. */ + zend_error(E_WARNING, + "Parameter %d to %s%s%s() expected to be a reference, value given", i+1, func->common.scope ? ZSTR_VAL(func->common.scope->name) : "", func->common.scope ? "::" : "", ZSTR_VAL(func->common.function_name)); - if (EG(current_execute_data) == &dummy_execute_data) { - EG(current_execute_data) = dummy_execute_data.prev_execute_data; - } - return FAILURE; } - - ZVAL_NEW_REF(arg, arg); } - Z_ADDREF_P(arg); } else { if (Z_ISREF_P(arg) && !(func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) { /* don't separate references for __call */ arg = Z_REFVAL_P(arg); } - if (Z_OPT_REFCOUNTED_P(arg)) { - Z_ADDREF_P(arg); - } } + param = ZEND_CALL_ARG(call, i+1); - ZVAL_COPY_VALUE(param, arg); + ZVAL_COPY(param, arg); } if (UNEXPECTED(func->op_array.fn_flags & ZEND_ACC_CLOSURE)) { |