From 36ded4215687d81a10f9e3205831c597df409e56 Mon Sep 17 00:00:00 2001 From: Zeev Suraski Date: Wed, 7 Mar 2001 10:07:25 +0000 Subject: [PATCH] Make parent:: work in runtime bindings as well --- Zend/zend_compile.c | 7 +++---- Zend/zend_execute.c | 13 +++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 020dce5079..439d0f34d4 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -871,10 +871,9 @@ void zend_do_begin_class_member_function_call(znode *class_name, znode *function opline->opcode = ZEND_INIT_FCALL_BY_NAME; zend_str_tolower(class_name->u.constant.value.str.val, class_name->u.constant.value.str.len); if ((class_name->u.constant.value.str.len == sizeof("parent")-1) - && !memcmp(class_name->u.constant.value.str.val, "parent", sizeof("parent")-1)) { - if (!CG(active_class_entry) || !CG(active_class_entry)->parent) { - zend_error(E_COMPILE_ERROR, "No parent class available in this context"); - } + && !memcmp(class_name->u.constant.value.str.val, "parent", sizeof("parent")-1) + && CG(active_class_entry) + && CG(active_class_entry)->parent) { efree(class_name->u.constant.value.str.val); class_name->u.constant.value.str.len = CG(active_class_entry)->parent->name_length; class_name->u.constant.value.str.val = estrndup(CG(active_class_entry)->parent->name, class_name->u.constant.value.str.len); diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 747def6ed6..5e02978937 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1401,10 +1401,6 @@ binary_assign_op_addr: { zend_class_entry *ce; zval **object_ptr_ptr; - if (zend_hash_find(EG(class_table), opline->op1.u.constant.value.str.val, opline->op1.u.constant.value.str.len+1, (void **) &ce)==FAILURE) { - zend_error(E_ERROR, "Undefined class name '%s'", opline->op1.u.constant.value.str.val); - } - active_function_table = &ce->function_table; if (zend_hash_find(EG(active_symbol_table), "this", sizeof("this"), (void **) &object_ptr_ptr)==FAILURE) { object.ptr=NULL; } else { @@ -1413,6 +1409,15 @@ binary_assign_op_addr: { object.ptr = *object_ptr_ptr; object.ptr->refcount++; /* For this pointer */ } + if (zend_hash_find(EG(class_table), opline->op1.u.constant.value.str.val, opline->op1.u.constant.value.str.len+1, (void **) &ce)==FAILURE) { /* class doesn't exist */ + /* test for parent:: special case - if it doesn't exist - error out */ + if (opline->op1.u.constant.value.str.len!=(sizeof("parent")-1) + || memcmp(opline->op1.u.constant.value.str.val, "parent", sizeof("parent")-1)!=0 + || !(ce = object.ptr->value.obj.ce->parent)) { + zend_error(E_ERROR, "Undefined class name '%s'", opline->op1.u.constant.value.str.val); + } + } + active_function_table = &ce->function_table; } else { /* used for member function calls */ object.ptr = _get_object_zval_ptr(&opline->op1, Ts, &EG(free_op1) ELS_CC); -- 2.40.0