fix regression bug #50394: Reference argument converted to value in __call

This commit is contained in:
Stanislav Malyshev 2009-12-18 19:12:11 +00:00
parent 8831f4ca23
commit 7f775864d1
3 changed files with 43 additions and 0 deletions

24
Zend/tests/bug50394.phpt Normal file
View File

@ -0,0 +1,24 @@
--TEST--
Bug #50394: Reference argument converted to value in __call
--FILE--
<?php
function inc( &$x ) { $x++; }
class Proxy {
function __call( $name, $args ) {
echo "$name called!\n";
call_user_func_array( 'inc', $args );
}
}
$arg = 1;
$args = array( &$arg );
$proxy = new Proxy;
call_user_func_array( array( $proxy, 'bar' ), $args );
call_user_func_array( array( $proxy, 'bar' ), array(&$arg) );
var_dump($arg);
--EXPECT--
bar called!
bar called!
int(3)

View File

@ -0,0 +1,18 @@
--TEST--
Check call to non-ref function with call-time refs
--FILE--
<?php
function my_errorhandler($errno,$errormsg) {
global $my_var;
$my_var=0x12345;
echo $errormsg."\n";
return true;
}
$oldhandler = set_error_handler("my_errorhandler");
$my_var = str_repeat("A",64);
$data = call_user_func_array("substr_replace",array(&$my_var, new StdClass(),1));
echo "OK!";
--EXPECT--
Object of class stdClass could not be converted to string
Object of class stdClass to string conversion
OK!

View File

@ -873,6 +873,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
zval *param;
if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION
&& (EX(function_state).function->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) == 0
&& !ARG_SHOULD_BE_SENT_BY_REF(EX(function_state).function, i + 1)
&& PZVAL_IS_REF(*fci->params[i])) {
SEPARATE_ZVAL(fci->params[i]);