From 8555c2bff01291e00e4e6af9f0df3b4fe848a390 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Wed, 29 Apr 2020 18:58:28 +0800 Subject: [PATCH] Fixed bug #79536 (zend_clear_exception prevent exception's destructor to be called). --- NEWS | 2 ++ Zend/zend_exceptions.c | 6 ++-- ext/soap/tests/bug79536.phpt | 63 ++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 ext/soap/tests/bug79536.phpt diff --git a/NEWS b/NEWS index bc5fc665e2..054ca007a1 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,8 @@ PHP NEWS ?? ??? ????, PHP 7.4.6 - Core: + . Fixed bug #79536 (zend_clear_exception prevent exception's destructor to be + called). (Laruence) . Fixed bug #78434 (Generator yields no items after valid() call). (Nikita) . Fixed bug #79477 (casting object into array creates references). (Nikita) . Fixed bug #79514 (Memory leaks while including unexistent file). (cmb, diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 8672ed8e00..937bf84292 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -179,16 +179,18 @@ ZEND_API ZEND_COLD void zend_throw_exception_internal(zval *exception) /* {{{ */ ZEND_API void zend_clear_exception(void) /* {{{ */ { + zend_object *exception; if (EG(prev_exception)) { - OBJ_RELEASE(EG(prev_exception)); EG(prev_exception) = NULL; } if (!EG(exception)) { return; } - OBJ_RELEASE(EG(exception)); + /* exception may have destructor */ + exception = EG(exception); EG(exception) = NULL; + OBJ_RELEASE(exception); if (EG(current_execute_data)) { EG(current_execute_data)->opline = EG(opline_before_exception); } diff --git a/ext/soap/tests/bug79536.phpt b/ext/soap/tests/bug79536.phpt new file mode 100644 index 0000000000..6de17fb762 --- /dev/null +++ b/ext/soap/tests/bug79536.phpt @@ -0,0 +1,63 @@ +--TEST-- +Bug #79536 (zend_clear_exception prevent exception's destructor to be called) +--SKIPIF-- + +--INI-- +soap.wsdl_cache_enabled=0 +--FILE-- + + + +??? + + + +"; + +class myFault extends SoapFault { + public function __destruct() { + } +} + +function book_to_xml($book) { + throw new myFault("Server", "Conversion Fault"); +} + +class test{ + function dotest2($str){ + $book = new book; + $book->a = "foo"; + $book->b = "bar"; + return $book; + } +} + +class book{ + public $a="a"; + public $b="c"; + +} + +$options=Array( + 'actor' =>'http://schemas.nothing.com', + 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", + "type_name" => "book", + "to_xml" => "book_to_xml")) + ); + +$server = new SoapServer(__DIR__."/classmap.wsdl",$options); +$server->setClass("test"); +$server->handle($HTTP_RAW_POST_DATA); +echo "ok\n"; +?> +--EXPECT-- + +SOAP-ENV:ServerConversion Fault +ok -- 2.40.0