From: Andi Gutmans Date: Mon, 14 Aug 2000 19:17:26 +0000 (+0000) Subject: - This patch should hopefully fix situations where a constructor uses X-Git-Tag: php-4.0.2RC1~115 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e46ea8864c3c2548010128b22c26382d9aafbd98;p=php - This patch should hopefully fix situations where a constructor uses - the $this pointer as a reference. --- diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 8e7f185b78..e2d8089f32 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1641,7 +1641,7 @@ void do_begin_new_object(znode *new_token, znode *class_name CLS_DC) unsigned char *ptr = NULL; opline->opcode = ZEND_NEW; - opline->result.op_type = IS_TMP_VAR; + opline->result.op_type = IS_VAR; opline->result.u.var = get_temporary_variable(CG(active_op_array)); opline->op1 = *class_name; SET_UNUSED(opline->op2); diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 7ac697a0e7..521eb2935d 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1411,7 +1411,7 @@ binary_assign_op_addr: { if (opline->extended_value & ZEND_CTOR_CALL) { /* constructor call */ - if (opline->op1.op_type == IS_VAR) { + if (opline->op1.op_type == IS_VAR && !(opline->op1.u.EA.type & EXT_TYPE_UNUSED)) { PZVAL_LOCK(*Ts[opline->op1.u.var].var.ptr_ptr); } if (opline->op2.op_type==IS_VAR) { @@ -1839,9 +1839,11 @@ send_by_ref: if (zend_hash_find(EG(class_table), class_name.value.str.val, class_name.value.str.len+1, (void **) &ce)==FAILURE) { zend_error(E_ERROR, "Cannot instantiate non-existent class: %s", class_name.value.str.val); } - object_init_ex(&Ts[opline->result.u.var].tmp_var, ce); - Ts[opline->result.u.var].tmp_var.refcount=1; - Ts[opline->result.u.var].tmp_var.is_ref=1; + Ts[opline->result.u.var].var.ptr_ptr = &Ts[opline->result.u.var].var.ptr; + ALLOC_ZVAL(Ts[opline->result.u.var].var.ptr); + object_init_ex(Ts[opline->result.u.var].var.ptr, ce); + Ts[opline->result.u.var].var.ptr->refcount=1; + Ts[opline->result.u.var].var.ptr->is_ref=1; zval_dtor(&class_name); FREE_OP(&opline->op1, EG(free_op1)); }