Skip to content

Commit acee66a

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fixed bug #79536 (zend_clear_exception prevent exception's destructor to be called).
2 parents faa57ab + 5d3b7ac commit acee66a

File tree

2 files changed

+67
-2
lines changed

2 files changed

+67
-2
lines changed

Zend/zend_exceptions.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,18 @@ ZEND_API ZEND_COLD void zend_throw_exception_internal(zval *exception) /* {{{ */
182182

183183
ZEND_API void zend_clear_exception(void) /* {{{ */
184184
{
185+
zend_object *exception;
185186
if (EG(prev_exception)) {
186-
187187
OBJ_RELEASE(EG(prev_exception));
188188
EG(prev_exception) = NULL;
189189
}
190190
if (!EG(exception)) {
191191
return;
192192
}
193-
OBJ_RELEASE(EG(exception));
193+
/* exception may have destructor */
194+
exception = EG(exception);
194195
EG(exception) = NULL;
196+
OBJ_RELEASE(exception);
195197
if (EG(current_execute_data)) {
196198
EG(current_execute_data)->opline = EG(opline_before_exception);
197199
}

ext/soap/tests/bug79536.phpt

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
--TEST--
2+
Bug #79536 (zend_clear_exception prevent exception's destructor to be called)
3+
--SKIPIF--
4+
<?php require_once('skipif.inc'); ?>
5+
--INI--
6+
soap.wsdl_cache_enabled=0
7+
--FILE--
8+
<?php
9+
$GLOBALS['HTTP_RAW_POST_DATA']="
10+
<env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\"
11+
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
12+
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
13+
xmlns:enc=\"http://schemas.xmlsoap.org/soap/encoding/\"
14+
xmlns:ns1=\"http://schemas.nothing.com\"
15+
>
16+
<env:Body>
17+
<ns1:dotest2>
18+
<dotest2 xsi:type=\"xsd:string\">???</dotest2>
19+
</ns1:dotest2>
20+
</env:Body>
21+
<env:Header/>
22+
</env:Envelope>";
23+
24+
class myFault extends SoapFault {
25+
public function __destruct() {
26+
}
27+
}
28+
29+
function book_to_xml($book) {
30+
throw new myFault("Server", "Conversion Fault");
31+
}
32+
33+
class test{
34+
function dotest2($str){
35+
$book = new book;
36+
$book->a = "foo";
37+
$book->b = "bar";
38+
return $book;
39+
}
40+
}
41+
42+
class book{
43+
public $a="a";
44+
public $b="c";
45+
46+
}
47+
48+
$options=Array(
49+
'actor' =>'http://schemas.nothing.com',
50+
'typemap' => array(array("type_ns" => "http://schemas.nothing.com",
51+
"type_name" => "book",
52+
"to_xml" => "book_to_xml"))
53+
);
54+
55+
$server = new SoapServer(__DIR__."/classmap.wsdl",$options);
56+
$server->setClass("test");
57+
$server->handle($HTTP_RAW_POST_DATA);
58+
echo "ok\n";
59+
?>
60+
--EXPECT--
61+
<?xml version="1.0" encoding="UTF-8"?>
62+
<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>
63+
ok

0 commit comments

Comments
 (0)