diff options
author | Xinchen Hui <laruence@gmail.com> | 2020-04-29 18:58:28 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@gmail.com> | 2020-04-29 18:58:28 +0800 |
commit | 8555c2bff01291e00e4e6af9f0df3b4fe848a390 (patch) | |
tree | 5fe5b3b2bf0805d9373fd30965dbf33be48857cb | |
parent | 3151676f520555bfadb39ea76779e93552d13fc1 (diff) | |
download | php-git-8555c2bff01291e00e4e6af9f0df3b4fe848a390.tar.gz |
Fixed bug #79536 (zend_clear_exception prevent exception's destructor to be called).
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | Zend/zend_exceptions.c | 6 | ||||
-rw-r--r-- | ext/soap/tests/bug79536.phpt | 63 |
3 files changed, 69 insertions, 2 deletions
@@ -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-- +<?php require_once('skipif.inc'); ?> +--INI-- +soap.wsdl_cache_enabled=0 +--FILE-- +<?php +$GLOBALS['HTTP_RAW_POST_DATA']=" +<env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\" + xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" + xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" + xmlns:enc=\"http://schemas.xmlsoap.org/soap/encoding/\" + xmlns:ns1=\"http://schemas.nothing.com\" +> + <env:Body> +<ns1:dotest2> +<dotest2 xsi:type=\"xsd:string\">???</dotest2> +</ns1:dotest2> + </env:Body> +<env:Header/> +</env:Envelope>"; + +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-- +<?xml version="1.0" encoding="UTF-8"?> +<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Server</faultcode><faultstring>Conversion Fault</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope> +ok |