cvs: ZendEngine2 / zend_object_handlers.c zend_object_handlers.h zend_objects.c

From: Date: Tue, 01 Jul 2003 19:13:50 +0000
Subject: cvs: ZendEngine2 / zend_object_handlers.c zend_object_handlers.h zend_objects.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-1421@lists.php.net to get a copy of this message
helly Tue Jul 1 15:13:50 2003 EDT Modified files: /ZendEngine2 zend_objects.c zend_object_handlers.c zend_object_handlers.h Log: Fix destructor visibility Index: ZendEngine2/zend_objects.c diff -u ZendEngine2/zend_objects.c:1.29 ZendEngine2/zend_objects.c:1.30 --- ZendEngine2/zend_objects.c:1.29 Tue Jun 10 16:03:25 2003 +++ ZendEngine2/zend_objects.c Tue Jul 1 15:13:50 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_objects.c,v 1.29 2003/06/10 20:03:25 imajes Exp $ */ +/* $Id: zend_objects.c,v 1.30 2003/07/01 19:13:50 helly Exp $ */ #include "zend.h" #include "zend_globals.h" @@ -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,12 +40,25 @@ 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); Index: ZendEngine2/zend_object_handlers.c diff -u ZendEngine2/zend_object_handlers.c:1.54 ZendEngine2/zend_object_handlers.c:1.55 --- ZendEngine2/zend_object_handlers.c:1.54 Sun Jun 29 19:41:49 2003 +++ ZendEngine2/zend_object_handlers.c Tue Jul 1 15:13:50 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_object_handlers.c,v 1.54 2003/06/29 23:41:49 iliaa Exp $ */ +/* $Id: zend_object_handlers.c,v 1.55 2003/07/01 19:13:50 helly Exp $ */ #include "zend.h" #include "zend_globals.h" @@ -516,7 +516,7 @@ /* 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; Index: ZendEngine2/zend_object_handlers.h diff -u ZendEngine2/zend_object_handlers.h:1.16 ZendEngine2/zend_object_handlers.h:1.17 --- ZendEngine2/zend_object_handlers.h:1.16 Tue Jun 10 16:03:25 2003 +++ ZendEngine2/zend_object_handlers.h Tue Jul 1 15:13:50 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_object_handlers.h,v 1.16 2003/06/10 20:03:25 imajes Exp $ */ +/* $Id: zend_object_handlers.h,v 1.17 2003/07/01 19:13:50 helly Exp $ */ #ifndef ZEND_OBJECT_HANDLERS_H #define ZEND_OBJECT_HANDLERS_H @@ -103,6 +103,8 @@ #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

« previous php.zend-engine.cvs (#1421) next »