From: Dmitry Stogov Date: Wed, 3 Sep 2014 12:30:48 +0000 (+0400) Subject: Disabled usage of built-in functions in write context (e.g. strlen($s)[] = ...) X-Git-Tag: PRE_PHP7_REMOVALS~135 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c52511c30703d2921f813ccf1557bc042a7cd9d2;p=php Disabled usage of built-in functions in write context (e.g. strlen($s)[] = ...) --- diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index a8ee529a80..0b42f9597b 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -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"); + } } } /* }}} */