summaryrefslogtreecommitdiff
path: root/Zend/zend_objects.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2010-05-11 16:09:43 +0000
committerDmitry Stogov <dmitry@php.net>2010-05-11 16:09:43 +0000
commitd352196bd6b6d9de5376f0695333435dc4b3538b (patch)
tree1ba443cbb81bba2668b5256cdf8c0f528385c609 /Zend/zend_objects.c
parent70b6fd2ae4f034a13936d162bc84ce196297ad1a (diff)
downloadphp-git-d352196bd6b6d9de5376f0695333435dc4b3538b.tar.gz
Fixed bug #49893 (Crash while creating an instance of Zend_Mail_Storage_Pop3)
Diffstat (limited to 'Zend/zend_objects.c')
-rw-r--r--Zend/zend_objects.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c
index 8b94e62d88..a2f1d3287e 100644
--- a/Zend/zend_objects.c
+++ b/Zend/zend_objects.c
@@ -52,6 +52,7 @@ ZEND_API void zend_objects_destroy_object(zend_object *object, zend_object_handl
zend_function *destructor = object ? object->ce->destructor : NULL;
if (destructor) {
+ zval *old_exception;
zval *obj;
zend_object_store_bucket *obj_bucket;
@@ -99,12 +100,25 @@ ZEND_API void zend_objects_destroy_object(zend_object *object, zend_object_handl
* For example, if an exception was thrown in a function and when the function's
* local variable destruction results in a destructor being called.
*/
- if (EG(exception) && Z_OBJ_HANDLE_P(EG(exception)) == handle) {
- zend_error(E_ERROR, "Attempt to destruct pending exception");
+ old_exception = NULL;
+ if (EG(exception)) {
+ if (Z_OBJ_HANDLE_P(EG(exception)) == handle) {
+ zend_error(E_ERROR, "Attempt to destruct pending exception");
+ } else {
+ old_exception = EG(exception);
+ Z_ADDREF_P(old_exception);
+ }
}
zend_exception_save(TSRMLS_C);
zend_call_method_with_0_params(&obj, object->ce, &destructor, ZEND_DESTRUCTOR_FUNC_NAME, NULL);
zend_exception_restore(TSRMLS_C);
+ if (old_exception) {
+ if (EG(exception)) {
+ zval_ptr_dtor(&old_exception);
+ } else {
+ EG(exception) = old_exception;
+ }
+ }
zval_ptr_dtor(&obj);
}
}