Skip to content

Commit 75eddcb

Browse files
committed
Disallow FCC with more than one arg, or non-variadic placeholder
1 parent 3a0d845 commit 75eddcb

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
First class callable error: more than one argument
3+
--FILE--
4+
<?php
5+
6+
foo(1, ...);
7+
8+
?>
9+
--EXPECTF--
10+
Fatal error: Cannot create a Closure for call expression with more than one argument, or non-variadic placeholders in %s on line %d
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
First class callable error: non-variadic placeholder
3+
--FILE--
4+
<?php
5+
6+
foo(?);
7+
8+
?>
9+
--EXPECTF--
10+
Fatal error: Cannot create a Closure for call expression with more than one argument, or non-variadic placeholders in %s on line %d

Zend/zend_compile.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3950,6 +3950,11 @@ static bool zend_compile_call_common(znode *result, zend_ast *args_ast, const ze
39503950
zend_error_noreturn(E_COMPILE_ERROR, "Cannot create Closure for new expression");
39513951
}
39523952

3953+
zend_ast_list *args = zend_ast_get_list(((zend_ast_fcc*)args_ast)->args);
3954+
if (args->children != 1 || args->child[0]->attr != _IS_PLACEHOLDER_VARIADIC) {
3955+
zend_error_noreturn(E_COMPILE_ERROR, "Cannot create a Closure for call expression with more than one argument, or non-variadic placeholders");
3956+
}
3957+
39533958
if (opcode == ZEND_INIT_FCALL) {
39543959
opline->op1.num = zend_vm_calc_used_stack(0, fbc);
39553960
}

0 commit comments

Comments
 (0)