]> granicus.if.org Git - php/commitdiff
Disabled usage of built-in functions in write context (e.g. strlen($s)[] = ...)
authorDmitry Stogov <dmitry@zend.com>
Wed, 3 Sep 2014 12:30:48 +0000 (16:30 +0400)
committerDmitry Stogov <dmitry@zend.com>
Wed, 3 Sep 2014 12:30:48 +0000 (16:30 +0400)
Zend/zend_compile.c

index a8ee529a80998467269a35118b9f1024e08f02c5..0b42f9597b37cac012982614578d17bb6856fb2f 100644 (file)
@@ -3604,9 +3604,13 @@ static void zend_compile_simple_var(znode *result, zend_ast *ast, uint32_t type
 static void zend_separate_if_call_and_write(znode *node, zend_ast *ast, uint32_t type TSRMLS_DC) /* {{{ */
 {
        if (type != BP_VAR_R && type != BP_VAR_IS && zend_is_call(ast)) {
-               zend_op *opline = zend_emit_op(NULL, ZEND_SEPARATE, node, NULL TSRMLS_CC);
-               opline->result_type = IS_VAR;
-               opline->result.var = opline->op1.var;
+               if (node->op_type == IS_VAR) {
+                       zend_op *opline = zend_emit_op(NULL, ZEND_SEPARATE, node, NULL TSRMLS_CC);
+                       opline->result_type = IS_VAR;
+                       opline->result.var = opline->op1.var;
+               } else {
+                       zend_error_noreturn(E_COMPILE_ERROR, "Cannot use result of built-in function in write context");
+               }
        }
 }
 /* }}} */