com php-src: Fixed by reference parameter passing from internal functions: Zend/zend_execute_API.c

From: Date: Wed, 05 Mar 2014 12:17:00 +0000
Subject: com php-src: Fixed by reference parameter passing from internal functions: Zend/zend_execute_API.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-77758@lists.php.net to get a copy of this message
Commit: 84c092f6d623a9e58963db84c507624a13b50e17 Author: Dmitry Stogov <dmitry@zend.com> Wed, 5 Mar 2014 16:17:00 +0400 Parents: da75df6faa19cfd6239661d5dddd865cf6616ed3 Branches: phpng Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=84c092f6d623a9e58963db84c507624a13b50e17 Log: Fixed by reference parameter passing from internal functions Changed paths: M Zend/zend_execute_API.c Diff: diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 3091b85..0d3637a 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -837,34 +837,33 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS zval *param; if (ARG_SHOULD_BE_SENT_BY_REF(EX(function_state).function, i + 1)) { - if (Z_REFCOUNTED(fci->params[i])) { - if (!Z_ISREF(fci->params[i]) && Z_REFCOUNT(fci->params[i]) > 1) { - zval new_zval; - - if (fci->no_separation && - !ARG_MAY_BE_SENT_BY_REF(EX(function_state).function, i + 1)) { - if (i || UNEXPECTED(ZEND_VM_STACK_ELEMETS(EG(argument_stack)) == (EG(argument_stack)->top))) { - /* hack to clean up the stack */ - ZVAL_LONG(&tmp, i); - zend_vm_stack_push(&tmp TSRMLS_CC); - zend_vm_stack_clear_multiple(0 TSRMLS_CC); - } - - zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given", - i+1, - EX(function_state).function->common.scope ? EX(function_state).function->common.scope->name->val : "", - EX(function_state).function->common.scope ? "::" : "", - EX(function_state).function->common.function_name->val); - return FAILURE; + if (!Z_REFCOUNTED(fci->params[i]) || + (!Z_ISREF(fci->params[i]) && Z_REFCOUNT(fci->params[i]) > 1)) { + + if (fci->no_separation && + !ARG_MAY_BE_SENT_BY_REF(EX(function_state).function, i + 1)) { + if (i || UNEXPECTED(ZEND_VM_STACK_ELEMETS(EG(argument_stack)) == (EG(argument_stack)->top))) { + /* hack to clean up the stack */ + ZVAL_LONG(&tmp, i); + zend_vm_stack_push(&tmp TSRMLS_CC); + zend_vm_stack_clear_multiple(0 TSRMLS_CC); } - ZVAL_DUP(&new_zval, &fci->params[i]); - Z_DELREF(fci->params[i]); - ZVAL_COPY_VALUE(&fci->params[i], &new_zval); + zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given", + i+1, + EX(function_state).function->common.scope ? EX(function_state).function->common.scope->name->val : "", + EX(function_state).function->common.scope ? "::" : "", + EX(function_state).function->common.function_name->val); + return FAILURE; } + + zval_copy_ctor(&fci->params[i]); + } else if (!Z_ISREF(fci->params[i])) { + ZVAL_NEW_REF(&fci->params[i], &fci->params[i]); + Z_ADDREF(fci->params[i]); + } else if (Z_REFCOUNTED(fci->params[i])) { Z_ADDREF(fci->params[i]); } -//??? Z_SET_ISREF_PP(fci->params[i]); param = &fci->params[i]; } else if (Z_ISREF(fci->params[i]) && /* don't separate references for __call */

« previous php.cvs (#77758) next »