cvs: ZendEngine2 / zend_compile.c /tests bug41117_1.phpt

From: Date: Wed, 02 May 2007 13:22:15 +0000
Subject: cvs: ZendEngine2 / zend_compile.c /tests bug41117_1.phpt
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-5765@lists.php.net to get a copy of this message
dmitry Wed May 2 13:22:15 2007 UTC Modified files: /ZendEngine2 zend_compile.c /ZendEngine2/tests bug41117_1.phpt Log: Fixed altering $this via argument named "this" http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.745&r2=1.746&diff_format=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.745 ZendEngine2/zend_compile.c:1.746 --- ZendEngine2/zend_compile.c:1.745 Mon Apr 16 09:43:52 2007 +++ ZendEngine2/zend_compile.c Wed May 2 13:22:15 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.745 2007/04/16 09:43:52 dmitry Exp $ */ +/* $Id: zend_compile.c,v 1.746 2007/05/02 13:22:15 dmitry Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -1342,9 +1342,18 @@ void zend_do_receive_arg(zend_uchar op, znode *var, znode *offset, znode *initialization, znode *class_type, znode *varname, zend_uchar pass_by_reference TSRMLS_DC) { - zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); + zend_op *opline; zend_arg_info *cur_arg_info; + if (CG(active_op_array)->scope && + ((CG(active_op_array)->fn_flags & ZEND_ACC_STATIC) == 0) && + (Z_TYPE(varname->u.constant) == IS_STRING || Z_TYPE(varname->u.constant) == IS_UNICODE) && + Z_UNILEN(varname->u.constant) == (sizeof("this")-1) && + ZEND_U_EQUAL(Z_TYPE(varname->u.constant), Z_UNIVAL(varname->u.constant), Z_UNILEN(varname->u.constant), "this", sizeof("this")-1)) { + zend_error(E_COMPILE_ERROR, "Cannot re-assign $this"); + } + + opline = get_next_op(CG(active_op_array) TSRMLS_CC); CG(active_op_array)->num_args++; opline->opcode = op; opline->result = *var; http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug41117_1.phpt?r1=1.1&r2=1.2&diff_format=u Index: ZendEngine2/tests/bug41117_1.phpt diff -u /dev/null ZendEngine2/tests/bug41117_1.phpt:1.2 --- /dev/null Wed May 2 13:22:15 2007 +++ ZendEngine2/tests/bug41117_1.phpt Wed May 2 13:22:15 2007 @@ -0,0 +1,14 @@ +--TEST-- +Bug #41117 (Altering $this via argument) +--FILE-- +<?php +class foo { + function __construct($this) { + echo $this."\n"; + } +} +$obj = new foo("Hello world"); +?> +--EXPECTF-- +Fatal error: Cannot re-assign $this in %sbug41117_1.php on line 3 +

« previous php.zend-engine.cvs (#5765) next »