summaryrefslogtreecommitdiff
path: root/Zend/zend_objects.c
diff options
context:
space:
mode:
authorAndi Gutmans <andi@php.net>2004-03-02 08:13:15 +0000
committerAndi Gutmans <andi@php.net>2004-03-02 08:13:15 +0000
commit3333380bf0da1aa744d19182cf6cef099681b4d6 (patch)
tree77930ebb3fe13df1f4524c08001e84f4fca14ae0 /Zend/zend_objects.c
parentee768a2fe6c3e58903392ad77867d952fcea4cd4 (diff)
downloadphp-git-3333380bf0da1aa744d19182cf6cef099681b4d6.tar.gz
- Improve fix for protecting destructor's from exceptions.
- I was killing the current exception completely which was wrong.
Diffstat (limited to 'Zend/zend_objects.c')
-rw-r--r--Zend/zend_objects.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c
index bc4ac86f34..85f76302fc 100644
--- a/Zend/zend_objects.c
+++ b/Zend/zend_objects.c
@@ -32,6 +32,7 @@ ZEND_API void zend_objects_destroy_object(zend_object *object, zend_object_handl
if (destructor) {
zval zobj, *obj = &zobj;
+ zval *old_exception;
if (destructor->op_array.fn_flags & (ZEND_ACC_PRIVATE|ZEND_ACC_PROTECTED)) {
if (destructor->op_array.fn_flags & ZEND_ACC_PRIVATE) {
@@ -68,15 +69,17 @@ ZEND_API void zend_objects_destroy_object(zend_object *object, zend_object_handl
zobj.value.obj.handlers = &std_object_handlers;
INIT_PZVAL(obj);
- if (EG(exception)) {
- zval_ptr_dtor(&EG(exception));
- EG(exception) = NULL;
- }
+ /* Make sure that destructors are protected from previously thrown exceptions.
+ * For example, if an exception was thrown in a function and when the function's
+ * local variable destruction results in a destructor being called.
+ */
+ old_exception = EG(exception);
+ EG(exception) = NULL;
zend_call_method_with_0_params(&obj, object->ce, NULL, "__destruct", NULL);
if (EG(exception)) {
zval_ptr_dtor(&EG(exception));
- EG(exception) = NULL;
}
+ EG(exception) = old_exception;
}
}