Fix destructor visibility

This commit is contained in:
Marcus Boerger 2003-07-01 19:13:50 +00:00
parent d2b1b6c700
commit 35c40932e8
3 changed files with 20 additions and 3 deletions

View file

@ -516,7 +516,7 @@ inline zend_function *zend_check_private(zend_function *fbc, zend_class_entry *c
/* Ensures that we're allowed to call a protected method.
*/
inline int zend_check_protected(zend_class_entry *ce, zend_class_entry *scope)
int zend_check_protected(zend_class_entry *ce, zend_class_entry *scope)
{
zend_class_entry *fbc_scope = ce;

View file

@ -104,6 +104,8 @@ zend_bool zend_std_unset_static_property(zend_class_entry *ce, char *property_na
#define IS_ZEND_STD_OBJECT(z) ((z).type == IS_OBJECT && (Z_OBJ_HT((z))->get_class_entry != NULL))
#define HAS_CLASS_ENTRY(z) (Z_OBJ_HT(z)->get_class_entry != NULL)
int zend_check_protected(zend_class_entry *ce, zend_class_entry *scope);
#endif
/*

View file

@ -26,7 +26,9 @@
static inline void zend_objects_call_destructor(zend_object *object, zend_object_handle handle TSRMLS_DC)
{
if (object->ce->destructor) {
zend_function *destructor = object->ce->destructor;
if (destructor) {
zval *obj;
zval *destructor_func_name;
zval *retval_ptr;
@ -38,13 +40,26 @@ static inline void zend_objects_call_destructor(zend_object *object, zend_object
obj->value.obj.handlers = &std_object_handlers;
zval_copy_ctor(obj);
/* FIXME: Optimize this so that we use the old_object->ce->destructor function pointer instead of the name */
MAKE_STD_ZVAL(destructor_func_name);
destructor_func_name->type = IS_STRING;
destructor_func_name->value.str.val = estrndup("__destruct", sizeof("__destruct")-1);
destructor_func_name->value.str.len = sizeof("__destruct")-1;
if (destructor->op_array.fn_flags & ZEND_ACC_PRIVATE) {
/* Ensure that if we're calling a private function, we're allowed to do so.
*/
if (object->ce != EG(scope)) {
zend_error(E_ERROR, "Call to private destructor from context '%s'", EG(scope) ? EG(scope)->name : "");
}
} else if ((destructor->common.fn_flags & ZEND_ACC_PROTECTED)) {
/* Ensure that if we're calling a protected function, we're allowed to do so.
*/
if (!zend_check_protected(destructor->common.scope, EG(scope))) {
zend_error(E_ERROR, "Call to protected destructor from context '%s'", EG(scope) ? EG(scope)->name : "");
}
}
ZEND_INIT_SYMTABLE(&symbol_table);
call_user_function_ex(NULL, &obj, destructor_func_name, &retval_ptr, 0, NULL, 0, &symbol_table TSRMLS_CC);