Skip to content

Commit 932406a

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix GH-16259: Soap segfault when classmap instantiation fails
2 parents 0338008 + 71222f7 commit 932406a

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ PHP NEWS
9797
. Fix Soap leaking http_msg on error. (nielsdos)
9898
. Fixed bug GH-16256 (Assertion failure in ext/soap/php_encoding.c:460).
9999
(nielsdos)
100+
. Fixed bug GH-16259 (Soap segfault when classmap instantiation fails).
101+
(nielsdos)
100102

101103
- SPL:
102104
. Fixed bug GH-15918 (Assertion failure in ext/spl/spl_fixedarray.c).

ext/soap/php_encoding.c

+15-5
Original file line numberDiff line numberDiff line change
@@ -1444,7 +1444,9 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z
14441444
return ret;
14451445
}
14461446

1447-
object_init_ex(ret, ce);
1447+
if (object_init_ex(ret, ce) != SUCCESS) {
1448+
return ret;
1449+
}
14481450
master_to_zval_int(&base, enc, data);
14491451
set_zval_property(ret, "_", &base);
14501452
} else {
@@ -1453,7 +1455,9 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z
14531455
if (soap_check_xml_ref(ret, data)) {
14541456
return ret;
14551457
}
1456-
object_init_ex(ret, ce);
1458+
if (object_init_ex(ret, ce) != SUCCESS) {
1459+
return ret;
1460+
}
14571461
soap_add_xml_ref(ret, data);
14581462
}
14591463
} else if (sdlType->kind == XSD_TYPEKIND_EXTENSION &&
@@ -1498,7 +1502,9 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z
14981502
return ret;
14991503
}
15001504

1501-
object_init_ex(ret, ce);
1505+
if (object_init_ex(ret, ce) != SUCCESS) {
1506+
return ret;
1507+
}
15021508
soap_add_xml_ref(ret, data);
15031509
master_to_zval_int(&base, sdlType->encode, data);
15041510
set_zval_property(ret, "_", &base);
@@ -1509,7 +1515,9 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z
15091515
if (soap_check_xml_ref(ret, data)) {
15101516
return ret;
15111517
}
1512-
object_init_ex(ret, ce);
1518+
if (object_init_ex(ret, ce) != SUCCESS) {
1519+
return ret;
1520+
}
15131521
soap_add_xml_ref(ret, data);
15141522
}
15151523
if (sdlType->model) {
@@ -1569,7 +1577,9 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z
15691577
return ret;
15701578
}
15711579

1572-
object_init_ex(ret, ce);
1580+
if (object_init_ex(ret, ce) != SUCCESS) {
1581+
return ret;
1582+
}
15731583
soap_add_xml_ref(ret, data);
15741584
trav = data->children;
15751585

ext/soap/tests/bugs/gh16259.phpt

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
GH-16259 (Soap segfault when classmap instantiation fails)
3+
--EXTENSIONS--
4+
soap
5+
--FILE--
6+
<?php
7+
abstract class CT_A1 {
8+
}
9+
class CT_A2 extends CT_A1 {
10+
}
11+
12+
$classMap = array("A1" => "CT_A1", "A2" => "CT_A2");
13+
$client = new SoapClient(__DIR__."/bug36575.wsdl", array("trace" => 1, "exceptions" => 0));
14+
$a2 = new CT_A2();
15+
$client->test($a2);
16+
$soapRequest = $client->__getLastRequest();
17+
18+
$server = new SoapServer(__DIR__."/bug36575.wsdl", array("classmap" => $classMap));
19+
$server->handle($soapRequest);
20+
?>
21+
--EXPECT--
22+
<?xml version="1.0" encoding="UTF-8"?>
23+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Server</faultcode><faultstring>Cannot instantiate abstract class CT_A1</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>

0 commit comments

Comments
 (0)