From: Stanislav Malyshev Date: Mon, 4 Aug 2003 09:10:52 +0000 (+0000) Subject: Fix #24884 - clone $this X-Git-Tag: RELEASE_1_2b5~57 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4d5152635071b489273e706dfb97297f65c1c6f0;p=php Fix #24884 - clone $this --- diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 4afc36f267..6e5feff036 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -3056,12 +3056,17 @@ int zend_new_handler(ZEND_OPCODE_HANDLER_ARGS) int zend_clone_handler(ZEND_OPCODE_HANDLER_ARGS) { - zval *obj = get_zval_ptr(&EX(opline)->op1, EX(Ts), &EG(free_op1), BP_VAR_R); + zval *obj; zend_class_entry *ce; zend_function *clone; zend_object_clone_obj_t clone_call; - - if (Z_TYPE_P(obj) != IS_OBJECT) { + if(EX(opline)->op1.op_type == IS_UNUSED) { + /* this */ + obj = EG(This); + } else { + obj = get_zval_ptr(&EX(opline)->op1, EX(Ts), &EG(free_op1), BP_VAR_R); + } + if (!obj || Z_TYPE_P(obj) != IS_OBJECT) { zend_error(E_WARNING, "__clone method called on non-object"); EX_T(EX(opline)->result.u.var).var.ptr = EG(error_zval_ptr); EX_T(EX(opline)->result.u.var).var.ptr->refcount++;