diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 6e5feff036d..a09c9144fc2 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -3056,16 +3056,11 @@ int zend_new_handler(ZEND_OPCODE_HANDLER_ARGS) int zend_clone_handler(ZEND_OPCODE_HANDLER_ARGS) { - zval *obj; + zval *obj = get_obj_zval_ptr(&EX(opline)->op1, EX(Ts), &EG(free_op1), BP_VAR_R); zend_class_entry *ce; zend_function *clone; zend_object_clone_obj_t clone_call; - 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);