diff --git a/Zend/tests/bug64677.phpt b/Zend/tests/bug64677.phpt new file mode 100644 index 00000000000..44a7c5fc6f3 --- /dev/null +++ b/Zend/tests/bug64677.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #64677 (execution operator `` stealing surrounding arguments) +--FILE-- +show_output('Files: ', trim(`cd .`)); // this gives invalid args to shell_exec +$cat->show_output('Files: ', `cd .`); // this causes a segmentation fault +$cat->show_output(`cd .`); // this causes a segmentation fault + +function show_outputa($prepend, $output) { + echo "Okey"; +} +show_outputa('Files: ', `cd .`); // this works as expected + +?> +--EXPECT-- +Okey diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 76807909183..3c0d753b664 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -5702,6 +5702,7 @@ void zend_do_shell_exec(znode *result, const znode *cmd TSRMLS_DC) /* {{{ */ GET_CACHE_SLOT(opline->op1.constant); opline->extended_value = 1; SET_UNUSED(opline->op2); + opline->op2.num = CG(context).nested_calls; GET_NODE(result, opline->result); if (CG(context).nested_calls + 1 > CG(active_op_array)->nested_calls) {