com php-src: Fix detection of write to built-in function for references: Zend/tests/builtin_in_write_context_error1.phpt Z
end/tests/builtin_in_write_context_error2.phpt Ze nd/zend_compile.c

From: Date: Tue, 23 Sep 2014 18:42:22 +0000
Subject: com php-src: Fix detection of write to built-in function for references: Zend/tests/builtin_in_write_context_error1.phpt Z
end/tests/builtin_in_write_context_error2.phpt Ze nd/zend_compile.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-81885@lists.php.net to get a copy of this message
Commit: 9070eb38e9c1d04c42590f4f7bda74e74c12029b Author: Nikita Popov <nikic@php.net> Tue, 23 Sep 2014 20:42:22 +0200 Parents: 231dcc94e86c2e6b664b1310816cb6566518613b Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9070eb38e9c1d04c42590f4f7bda74e74c12029b Log: Fix detection of write to built-in function for references Changed paths: A Zend/tests/builtin_in_write_context_error1.phpt A Zend/tests/builtin_in_write_context_error2.phpt M Zend/zend_compile.c Diff: diff --git a/Zend/tests/builtin_in_write_context_error1.phpt b/Zend/tests/builtin_in_write_context_error1.phpt new file mode 100644 index 0000000..eed03cc --- /dev/null +++ b/Zend/tests/builtin_in_write_context_error1.phpt @@ -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 diff --git a/Zend/tests/builtin_in_write_context_error2.phpt b/Zend/tests/builtin_in_write_context_error2.phpt new file mode 100644 index 0000000..aac23e4 --- /dev/null +++ b/Zend/tests/builtin_in_write_context_error2.phpt @@ -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 diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 189d683..73f6a8b 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -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;

« previous php.cvs (#81885) next »