cvs: ZendEngine2 / zend_execute.c
| From: | Marcus Boerger | Date: | Tue, 01 Jul 2003 20:02:27 +0000 |
| Subject: | cvs: ZendEngine2 / zend_execute.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-1422@lists.php.net to get a copy of this message | ||
helly Tue Jul 1 16:02:27 2003 EDT
Modified files:
/ZendEngine2 zend_execute.c
Log:
Fix __clone visibility
Index: ZendEngine2/zend_execute.c
diff -u ZendEngine2/zend_execute.c:1.481 ZendEngine2/zend_execute.c:1.482
--- ZendEngine2/zend_execute.c:1.481 Mon Jun 30 16:22:35 2003
+++ ZendEngine2/zend_execute.c Tue Jul 1 16:02:27 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_execute.c,v 1.481 2003/06/30 20:22:35 andi Exp $ */
+/* $Id: zend_execute.c,v 1.482 2003/07/01 20:02:27 helly Exp $ */
#define ZEND_INTENSIVE_DEBUGGING 0
@@ -3129,6 +3129,8 @@
int zend_clone_handler(ZEND_OPCODE_HANDLER_ARGS)
{
zval *obj = get_zval_ptr(&EX(opline)->op1, EX(Ts), &EG(free_op1), BP_VAR_R);
+ zend_class_entry *ce;
+ zend_function *clone;
if (Z_TYPE_P(obj) != IS_OBJECT) {
zend_error(E_WARNING, "__clone method called on non-object");
@@ -3136,6 +3138,24 @@
EX_T(EX(opline)->result.u.var).var.ptr->refcount++;
NEXT_OPCODE();
}
+
+ ce = Z_OBJCE_P(obj);
+ clone = ce->clone;
+
+ if (clone->op_array.fn_flags & ZEND_ACC_PRIVATE) {
+ /* Ensure that if we're calling a private function, we're allowed to do so.
+ */
+ if (ce != EG(scope)) {
+ zend_error(E_ERROR, "Call to private __clone from context '%s'", EG(scope) ?
EG(scope)->name : "");
+ }
+ } else if ((clone->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(clone->common.scope, EG(scope))) {
+ zend_error(E_ERROR, "Call to protected __clone from context '%s'", EG(scope)
? EG(scope)->name : "");
+ }
+ }
+
EX_T(EX(opline)->result.u.var).var.ptr_ptr = &EX_T(EX(opline)->result.u.var).var.ptr;
ALLOC_ZVAL(EX_T(EX(opline)->result.u.var).var.ptr);
EX_T(EX(opline)->result.u.var).var.ptr->value.obj = Z_OBJ_HT_P(obj)->clone_obj(obj
TSRMLS_CC);