Skip to content

Commit

Permalink
Fix SEND_USER as well
Browse files Browse the repository at this point in the history
Missed copy&paste code here
  • Loading branch information
nikic committed Apr 18, 2016
1 parent a879215 commit 73958ca
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
26 changes: 26 additions & 0 deletions Zend/tests/call_user_func_array_prefer_ref.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ namespace {
call_user_func_array('array_multisort', $args);
var_dump($args);
unset($args);

$array = [3, 2, 1];
call_user_func('array_multisort', $array);
var_dump($array);
unset($array);
}

namespace Foo {
Expand All @@ -19,6 +24,11 @@ namespace Foo {
call_user_func_array('array_multisort', $args);
var_dump($args);
unset($args);

$array = [3, 2, 1];
call_user_func('array_multisort', $array);
var_dump($array);
unset($array);
}

?>
Expand All @@ -34,6 +44,14 @@ array(1) {
int(1)
}
}
array(3) {
[0]=>
int(3)
[1]=>
int(2)
[2]=>
int(1)
}
array(1) {
[0]=>
array(3) {
Expand All @@ -45,3 +63,11 @@ array(1) {
int(1)
}
}
array(3) {
[0]=>
int(3)
[1]=>
int(2)
[2]=>
int(1)
}
9 changes: 1 addition & 8 deletions Zend/zend_vm_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -4655,7 +4655,6 @@ ZEND_VM_HANDLER(120, ZEND_SEND_USER, VAR|CV, ANY)

if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
if (UNEXPECTED(!Z_ISREF_P(arg))) {

if (!ARG_MAY_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {

zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given",
Expand All @@ -4678,21 +4677,15 @@ ZEND_VM_HANDLER(120, ZEND_SEND_USER, VAR|CV, ANY)
FREE_OP1();
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}

ZVAL_NEW_REF(arg, arg);
}
Z_ADDREF_P(arg);
} else {
if (Z_ISREF_P(arg) &&
!(EX(call)->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);
}
}
ZVAL_COPY_VALUE(param, arg);
ZVAL_COPY(param, arg);

FREE_OP1();
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
Expand Down
18 changes: 2 additions & 16 deletions Zend/zend_vm_execute.h
Original file line number Diff line number Diff line change
Expand Up @@ -15331,7 +15331,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_USER_SPEC_VAR_HANDLER(ZEN

if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
if (UNEXPECTED(!Z_ISREF_P(arg))) {

if (!ARG_MAY_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {

zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given",
Expand All @@ -15354,21 +15353,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_USER_SPEC_VAR_HANDLER(ZEN
zval_ptr_dtor_nogc(free_op1);
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}

ZVAL_NEW_REF(arg, arg);
}
Z_ADDREF_P(arg);
} else {
if (Z_ISREF_P(arg) &&
!(EX(call)->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);
}
}
ZVAL_COPY_VALUE(param, arg);
ZVAL_COPY(param, arg);

zval_ptr_dtor_nogc(free_op1);
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
Expand Down Expand Up @@ -28945,7 +28938,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_USER_SPEC_CV_HANDLER(ZEND

if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
if (UNEXPECTED(!Z_ISREF_P(arg))) {

if (!ARG_MAY_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {

zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given",
Expand All @@ -28967,21 +28959,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_USER_SPEC_CV_HANDLER(ZEND

ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}

ZVAL_NEW_REF(arg, arg);
}
Z_ADDREF_P(arg);
} else {
if (Z_ISREF_P(arg) &&
!(EX(call)->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);
}
}
ZVAL_COPY_VALUE(param, arg);
ZVAL_COPY(param, arg);

ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
Expand Down

0 comments on commit 73958ca

Please sign in to comment.