mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
Fixed bug #49893 (Crash while creating an instance of Zend_Mail_Storage_Pop3)
This commit is contained in:
parent
70b6fd2ae4
commit
d352196bd6
28
Zend/tests/bug49893.phpt
Normal file
28
Zend/tests/bug49893.phpt
Normal file
@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
Bug #49893 (Crash while creating an instance of Zend_Mail_Storage_Pop3)
|
||||
--FILE--
|
||||
<?php
|
||||
class A {
|
||||
function __destruct() {
|
||||
try {
|
||||
throw new Exception("2");
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
class B {
|
||||
function __construct() {
|
||||
$this->a = new A();
|
||||
throw new Exception("1");
|
||||
}
|
||||
}
|
||||
try {
|
||||
$b = new B();
|
||||
} catch(Exception $e) {
|
||||
echo $e->getMessage() . "\n";;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
2
|
||||
1
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user