Skip to content

Commit 361d3ed

Browse files
committed
Fix bug #77410
1 parent 1ed2066 commit 361d3ed

File tree

4 files changed

+92
-2
lines changed

4 files changed

+92
-2
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ PHP NEWS
3535
. Fixed bug #77273 (array_walk_recursive corrupts value types leading to PDO
3636
failure). (Nikita)
3737

38+
- SOAP:
39+
. Fixed bug #77410 (Segmentation Fault when executing method with an empty
40+
parameter). (Nikita)
41+
3842
- Sockets:
3943
. Fixed bug #76839 (socket_recvfrom may return an invalid 'from' address
4044
on MacOS). (Michael Meyer)

ext/soap/php_encoding.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,9 +1856,9 @@ static xmlNodePtr to_xml_object(encodeTypePtr type, zval *data, int style, xmlNo
18561856
sdlType->encode->details.sdl_type->kind != XSD_TYPEKIND_LIST &&
18571857
sdlType->encode->details.sdl_type->kind != XSD_TYPEKIND_UNION) {
18581858

1859-
if (prop) {GC_PROTECT_RECURSION(prop);}
1859+
if (prop) { GC_TRY_PROTECT_RECURSION(prop); }
18601860
xmlParam = master_to_xml(sdlType->encode, data, style, parent);
1861-
if (prop) {GC_UNPROTECT_RECURSION(prop);}
1861+
if (prop) { GC_TRY_UNPROTECT_RECURSION(prop); }
18621862
} else {
18631863
zval rv;
18641864
zval *tmp = get_zval_property(data, "_", &rv);

ext/soap/tests/bug77410.phpt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Bug #77410: Segmentation Fault when executing method with an empty parameter
3+
--SKIPIF--
4+
<?php require_once('skipif.inc'); ?>
5+
--FILE--
6+
<?php
7+
8+
$client = new class(__DIR__ . '/bug77410.wsdl', [
9+
'cache_wsdl' => WSDL_CACHE_NONE,
10+
'trace' => 1,
11+
]) extends SoapClient {
12+
public function __doRequest($request, $location, $action, $version, $one_way = 0) {
13+
echo $request, "\n";
14+
return '';
15+
}
16+
};
17+
18+
$client->MyMethod([
19+
'parameter' => [],
20+
]);
21+
22+
?>
23+
--EXPECT--
24+
<?xml version="1.0" encoding="UTF-8"?>
25+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:test"><SOAP-ENV:Body><ns1:MyMethodRequest><parameter/></ns1:MyMethodRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>

ext/soap/tests/bug77410.wsdl

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<definitions targetNamespace="urn:test"
3+
xmlns="http://schemas.xmlsoap.org/wsdl/"
4+
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
5+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
6+
xmlns:test="urn:test"
7+
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
8+
9+
<portType name="TestPortType">
10+
<operation name="MyMethod">
11+
<input message="test:MyMethodRequestMessage" />
12+
<output message="test:MyMethodResponseMessage" />
13+
</operation>
14+
</portType>
15+
16+
<binding name="TestBinding" type="test:TestPortType">
17+
<operation name="MyMethod">
18+
<input><soap:body use="literal" /></input>
19+
<output><soap:body use="literal" /></output>
20+
</operation>
21+
</binding>
22+
23+
<message name="MyMethodRequestMessage">
24+
<part name="parameters" element="test:MyMethodRequest" />
25+
</message>
26+
27+
<message name="MyMethodResponseMessage">
28+
<part name="parameters" element="test:MyMethodResponse" />
29+
</message>
30+
31+
<types>
32+
<schema targetNamespace="urn:test" xmlns="http://www.w3.org/2001/XMLSchema">
33+
34+
<element name="MyMethodRequest">
35+
<complexType>
36+
<sequence>
37+
<element name="parameter" type="test:MyMethodRequestObject" />
38+
</sequence>
39+
</complexType>
40+
</element>
41+
42+
<element name="MyMethodResponse" />
43+
44+
<complexType name="MyMethodRequestObject">
45+
<complexContent>
46+
<extension base="test:DynamicData" />
47+
</complexContent>
48+
</complexType>
49+
50+
<complexType name="DynamicData" />
51+
52+
</schema>
53+
</types>
54+
55+
<service name="TestService">
56+
<port binding="test:TestBinding" name="TestPort">
57+
<soap:address location="http://localhost:8080/test-service" />
58+
</port>
59+
</service>
60+
61+
</definitions>

0 commit comments

Comments
 (0)