mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
Fix detection of write to built-in function for references
This commit is contained in:
parent
231dcc94e8
commit
9070eb38e9
10
Zend/tests/builtin_in_write_context_error1.phpt
Normal file
10
Zend/tests/builtin_in_write_context_error1.phpt
Normal file
@ -0,0 +1,10 @@
|
||||
--TEST--
|
||||
Cannot use built-in functions in write context (assignment)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
strlen("foo")[0] = 1;
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Cannot use result of built-in function in write context in %s on line %d
|
10
Zend/tests/builtin_in_write_context_error2.phpt
Normal file
10
Zend/tests/builtin_in_write_context_error2.phpt
Normal file
@ -0,0 +1,10 @@
|
||||
--TEST--
|
||||
Cannot use built-in functions in write context (reference)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$ref =& strlen("foo");
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Cannot use result of built-in function in write context in %s on line %d
|
@ -2322,6 +2322,10 @@ void zend_compile_assign_ref(znode *result, zend_ast *ast TSRMLS_DC) /* {{{ */
|
||||
zend_compile_var(&target_node, target_ast, BP_VAR_W TSRMLS_CC);
|
||||
zend_compile_var(&source_node, source_ast, BP_VAR_REF TSRMLS_CC);
|
||||
|
||||
if (source_node.op_type != IS_VAR && zend_is_call(source_ast)) {
|
||||
zend_error_noreturn(E_COMPILE_ERROR, "Cannot use result of built-in function in write context");
|
||||
}
|
||||
|
||||
opline = zend_emit_op(result, ZEND_ASSIGN_REF, &target_node, &source_node TSRMLS_CC);
|
||||
if (!result) {
|
||||
opline->result_type |= EXT_TYPE_UNUSED;
|
||||
|
Loading…
Reference in New Issue
Block a user