[php-src] master: Merge branch 'PHP-8.6'
| From: | David Carlier | Date: | Mon, 09 Nov 2026 13:29:45 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.6' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143479@lists.php.net to get a copy of this message | ||
Author: David Carlier (devnexen)
Date: 2026-11-09T13:27:37Z
Commit: https://github.com/php/php-src/commit/efd8d997b2d9d30fb1ded5820b583f13ce6d6f4c
Raw diff: https://github.com/php/php-src/commit/efd8d997b2d9d30fb1ded5820b583f13ce6d6f4c.diff
Merge branch 'PHP-8.6'
* PHP-8.6:
Fix GH-25303: NULL encoder dereference in to_xml_list() error message
Changed paths:
A ext/soap/tests/gh25303.phpt
M ext/soap/php_encoding.c
Diff:
diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c
index 53a43000ad3d..45dbe1d95076 100644
--- a/ext/soap/php_encoding.c
+++ b/ext/soap/php_encoding.c
@@ -3076,6 +3076,17 @@ static zval* to_zval_list(zval *ret, encodeTypePtr enc, xmlNodePtr data) {
return to_zval_stringc(ret, enc, data);
}
+static void to_xml_list_item_error(encodeTypePtr enc, encodePtr list_enc)
+{
+ if (enc->sdl_type && enc->sdl_type->kind == XSD_TYPEKIND_UNION) {
+ soap_error1(E_ERROR, "Encoding: Value does not match any member type of union type
'%s'",
+ soap_type_name(enc));
+ } else {
+ soap_error2(E_ERROR, "Encoding: Failed to encode list item of type '%s' for list
type '%s'",
+ soap_type_name(list_enc ? &list_enc->details : NULL), soap_type_name(enc));
+ }
+}
+
static xmlNodePtr to_xml_list(encodeTypePtr enc, zval *data, int style, xmlNodePtr parent) {
xmlNodePtr ret;
encodePtr list_enc = NULL;
@@ -3111,9 +3122,7 @@ static xmlNodePtr to_xml_list(encodeTypePtr enc, zval *data, int style,
xmlNodeP
}
smart_str_appends(&list, (char*)dummy->children->content);
} else {
- soap_error2(E_ERROR,
- "Encoding: Failed to encode list item of type '%s' for list type
'%s'",
- soap_type_name(&list_enc->details), soap_type_name(enc));
+ to_xml_list_item_error(enc, list_enc);
}
xmlUnlinkNode(dummy);
xmlFreeNode(dummy);
@@ -3155,9 +3164,7 @@ static xmlNodePtr to_xml_list(encodeTypePtr enc, zval *data, int style,
xmlNodeP
}
smart_str_appends(&list, (char*)dummy->children->content);
} else {
- soap_error2(E_ERROR,
- "Encoding: Failed to encode list item of type '%s' for list type
'%s'",
- soap_type_name(&list_enc->details), soap_type_name(enc));
+ to_xml_list_item_error(enc, list_enc);
}
xmlUnlinkNode(dummy);
xmlFreeNode(dummy);
diff --git a/ext/soap/tests/gh25303.phpt b/ext/soap/tests/gh25303.phpt
new file mode 100644
index 000000000000..d58c36d4efdc
--- /dev/null
+++ b/ext/soap/tests/gh25303.phpt
@@ -0,0 +1,36 @@
+--TEST--
+GH-25303 (NULL encode dereference in to_xml_list() error path for union types)
+--EXTENSIONS--
+soap
+--CREDITS--
+YuanchengJiang
+--FILE--
+<?php
+$wsdl = <<<XML
+<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="urn:t" targetNamespace="urn:t">
+ <types>
+ <xsd:schema targetNamespace="urn:t">
+ <xsd:simpleType name="U"><xsd:union
memberTypes="xsd:int"/></xsd:simpleType>
+ </xsd:schema>
+ </types>
+ <message name="m"><part name="p"
type="tns:U"/></message>
+ <portType name="pt"><operation name="test"><input
message="tns:m"/></operation></portType>
+ <binding name="b" type="tns:pt">
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <operation name="test"><soap:operation soapAction="#test"/>
+ <input><soap:body use="encoded" namespace="urn:t"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
+ </operation>
+ </binding>
+ <service name="s"><port name="p"
binding="tns:b"><soap:address
location="test://"/></port></service>
+</definitions>
+XML;
+$c = new SoapClient("data://text/plain;base64," . base64_encode($wsdl),
["cache_wsdl" => WSDL_CACHE_NONE]);
+try {
+ $c->test([[1]]);
+} catch (SoapFault $e) {
+ echo $e->getMessage(), "\n";
+}
+?>
+--EXPECT--
+SOAP-ERROR: Encoding: Value does not match any member type of union type 'U'