- This patch should hopefully fix situations where a constructor uses

- the $this pointer as a reference.
This commit is contained in:
Andi Gutmans 2000-08-14 19:17:26 +00:00
parent 51fe68fd51
commit e46ea8864c
2 changed files with 7 additions and 5 deletions

View File

@ -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);

View File

@ -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));
}