From 728acc3785ec9ca6b2233ee8071805d139dda2bd Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 3 Oct 2005 08:21:51 +0000 Subject: [PATCH] Fixed bug #34358 (Fatal error: Cannot re-assign $this) --- NEWS | 1 + Zend/tests/bug34358.phpt | 15 +++++++++++++++ Zend/zend_compile.c | 6 ++++-- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100755 Zend/tests/bug34358.phpt diff --git a/NEWS b/NEWS index 4e2e5f2c590..db218c490b4 100644 --- a/NEWS +++ b/NEWS @@ -58,6 +58,7 @@ PHP NEWS - Fixed bug #34450 (Segfault when calling mysqli_close() in destructor). (Tony) - Fixed bug #34449 (ext/soap: XSD_ANYXML functionality not exposed). (Dmitry) - Fixed bug #34420 (Possible crash inside curl_multi_remove_handle()). (Ilia) +- Fixed bug #34358 (Fatal error: Cannot re-assign $this). (Dmitry) - Fixed bug #34331 (php crashes when variables_order is empty). (Ilia) - Fixed bug #34321 (Possible crash in filter code). (Ilia) - Fixed bug #34311 (unserialize() crashes with chars above 191 dec). (Nuno) diff --git a/Zend/tests/bug34358.phpt b/Zend/tests/bug34358.phpt new file mode 100755 index 00000000000..b9c6565f51d --- /dev/null +++ b/Zend/tests/bug34358.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #34358 (Fatal error: Cannot re-assign $this(again)) +--FILE-- +bar(); +echo "ok\n"; +?> +--EXPECT-- +ok diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index a89fb34e744..4ea2d7c4bc3 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -567,7 +567,8 @@ void zend_do_assign(znode *result, znode *variable, znode *value TSRMLS_DC) *result = last_op->result; return; } else { - if (opline_is_fetch_this(last_op TSRMLS_CC)) { + if (variable->op_type == IS_VAR && + opline_is_fetch_this(last_op TSRMLS_CC)) { zend_error(E_COMPILE_ERROR, "Cannot re-assign $this"); } } @@ -597,7 +598,8 @@ void zend_do_assign_ref(znode *result, znode *lvar, znode *rvar TSRMLS_DC) if (last_op_number > 0) { zend_op *last_op = &CG(active_op_array)->opcodes[last_op_number-1]; - if (opline_is_fetch_this(last_op TSRMLS_CC)) { + if (lvar->op_type == IS_VAR && + opline_is_fetch_this(last_op TSRMLS_CC)) { zend_error(E_COMPILE_ERROR, "Cannot re-assign $this"); } }