1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.2' into PHP-8.3

* PHP-8.2:
  Fix GH-16259: Soap segfault when classmap instantiation fails
This commit is contained in:
Niels Dossche
2024-10-07 17:42:54 +02:00
3 changed files with 40 additions and 5 deletions

2
NEWS
View File

@@ -97,6 +97,8 @@ PHP NEWS
. Fix Soap leaking http_msg on error. (nielsdos)
. Fixed bug GH-16256 (Assertion failure in ext/soap/php_encoding.c:460).
(nielsdos)
. Fixed bug GH-16259 (Soap segfault when classmap instantiation fails).
(nielsdos)
- SPL:
. Fixed bug GH-15918 (Assertion failure in ext/spl/spl_fixedarray.c).

View File

@@ -1444,7 +1444,9 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z
return ret;
}
object_init_ex(ret, ce);
if (object_init_ex(ret, ce) != SUCCESS) {
return ret;
}
master_to_zval_int(&base, enc, data);
set_zval_property(ret, "_", &base);
} else {
@@ -1453,7 +1455,9 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z
if (soap_check_xml_ref(ret, data)) {
return ret;
}
object_init_ex(ret, ce);
if (object_init_ex(ret, ce) != SUCCESS) {
return ret;
}
soap_add_xml_ref(ret, data);
}
} else if (sdlType->kind == XSD_TYPEKIND_EXTENSION &&
@@ -1498,7 +1502,9 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z
return ret;
}
object_init_ex(ret, ce);
if (object_init_ex(ret, ce) != SUCCESS) {
return ret;
}
soap_add_xml_ref(ret, data);
master_to_zval_int(&base, sdlType->encode, data);
set_zval_property(ret, "_", &base);
@@ -1509,7 +1515,9 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z
if (soap_check_xml_ref(ret, data)) {
return ret;
}
object_init_ex(ret, ce);
if (object_init_ex(ret, ce) != SUCCESS) {
return ret;
}
soap_add_xml_ref(ret, data);
}
if (sdlType->model) {
@@ -1569,7 +1577,9 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z
return ret;
}
object_init_ex(ret, ce);
if (object_init_ex(ret, ce) != SUCCESS) {
return ret;
}
soap_add_xml_ref(ret, data);
trav = data->children;

View File

@@ -0,0 +1,23 @@
--TEST--
GH-16259 (Soap segfault when classmap instantiation fails)
--EXTENSIONS--
soap
--FILE--
<?php
abstract class CT_A1 {
}
class CT_A2 extends CT_A1 {
}
$classMap = array("A1" => "CT_A1", "A2" => "CT_A2");
$client = new SoapClient(__DIR__."/bug36575.wsdl", array("trace" => 1, "exceptions" => 0));
$a2 = new CT_A2();
$client->test($a2);
$soapRequest = $client->__getLastRequest();
$server = new SoapServer(__DIR__."/bug36575.wsdl", array("classmap" => $classMap));
$server->handle($soapRequest);
?>
--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>Cannot instantiate abstract class CT_A1</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>