Skip to content

Commit 0d564de

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix GH-16259: Soap segfault when classmap instantiation fails
2 parents 5b1f1b4 + 82d58c4 commit 0d564de

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

ext/soap/php_encoding.c

+15-5
Original file line numberDiff line numberDiff line change
@@ -1457,7 +1457,9 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z
14571457
return ret;
14581458
}
14591459

1460-
object_init_ex(ret, ce);
1460+
if (object_init_ex(ret, ce) != SUCCESS) {
1461+
return ret;
1462+
}
14611463
master_to_zval_int(&base, enc, data);
14621464
set_zval_property(ret, "_", &base);
14631465
} else {
@@ -1466,7 +1468,9 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z
14661468
if (soap_check_xml_ref(ret, data)) {
14671469
return ret;
14681470
}
1469-
object_init_ex(ret, ce);
1471+
if (object_init_ex(ret, ce) != SUCCESS) {
1472+
return ret;
1473+
}
14701474
soap_add_xml_ref(ret, data);
14711475
}
14721476
} else if (sdlType->kind == XSD_TYPEKIND_EXTENSION &&
@@ -1511,7 +1515,9 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z
15111515
return ret;
15121516
}
15131517

1514-
object_init_ex(ret, ce);
1518+
if (object_init_ex(ret, ce) != SUCCESS) {
1519+
return ret;
1520+
}
15151521
soap_add_xml_ref(ret, data);
15161522
master_to_zval_int(&base, sdlType->encode, data);
15171523
set_zval_property(ret, "_", &base);
@@ -1522,7 +1528,9 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z
15221528
if (soap_check_xml_ref(ret, data)) {
15231529
return ret;
15241530
}
1525-
object_init_ex(ret, ce);
1531+
if (object_init_ex(ret, ce) != SUCCESS) {
1532+
return ret;
1533+
}
15261534
soap_add_xml_ref(ret, data);
15271535
}
15281536
if (sdlType->model) {
@@ -1582,7 +1590,9 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z
15821590
return ret;
15831591
}
15841592

1585-
object_init_ex(ret, ce);
1593+
if (object_init_ex(ret, ce) != SUCCESS) {
1594+
return ret;
1595+
}
15861596
soap_add_xml_ref(ret, data);
15871597
trav = data->children;
15881598

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)