Skip to content

Commit 8555c2b

Browse files
committed
Fixed bug #79536 (zend_clear_exception prevent exception's destructor to be called).
1 parent 3151676 commit 8555c2b

File tree

3 files changed

+69
-2
lines changed

3 files changed

+69
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ PHP NEWS
44
?? ??? ????, PHP 7.4.6
55

66
- Core:
7+
. Fixed bug #79536 (zend_clear_exception prevent exception's destructor to be
8+
called). (Laruence)
79
. Fixed bug #78434 (Generator yields no items after valid() call). (Nikita)
810
. Fixed bug #79477 (casting object into array creates references). (Nikita)
911
. Fixed bug #79514 (Memory leaks while including unexistent file). (cmb,

Zend/zend_exceptions.c

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

180180
ZEND_API void zend_clear_exception(void) /* {{{ */
181181
{
182+
zend_object *exception;
182183
if (EG(prev_exception)) {
183-
184184
OBJ_RELEASE(EG(prev_exception));
185185
EG(prev_exception) = NULL;
186186
}
187187
if (!EG(exception)) {
188188
return;
189189
}
190-
OBJ_RELEASE(EG(exception));
190+
/* exception may have destructor */
191+
exception = EG(exception);
191192
EG(exception) = NULL;
193+
OBJ_RELEASE(exception);
192194
if (EG(current_execute_data)) {
193195
EG(current_execute_data)->opline = EG(opline_before_exception);
194196
}

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)