[php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5
David Carlier <[email protected]>
| Newsgroups | gmane.comp.php.cvs.general |
|---|---|
| Message-ID | <[email protected]> |
Author: David Carlier (devnexen)
Date: 2026-08-30T12:50:49+01:00
Commit: https://github.com/php/php-src/commit/89c7271f6bb9eb73ea89aa212dfbd825c288f0ee
Raw diff: https://github.com/php/php-src/commit/89c7271f6bb9eb73ea89aa212dfbd825c288f0ee.diff
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
Fix GH-23447: segfault when the SoapServer class fails to initialize
Changed paths:
A ext/soap/tests/gh23447.phpt
M ext/soap/soap.c
Diff:
diff --git a/ext/soap/soap.c b/ext/soap/soap.c
index 2b6a32d3265f..0962a2d70344 100644
--- a/ext/soap/soap.c
+++ b/ext/soap/soap.c
@@ -1491,7 +1491,11 @@ PHP_METHOD(SoapServer, handle)
/* If new session or something weird happned */
if (soap_obj == NULL) {
- object_init_ex(&tmp_soap, service->soap_class.ce);
+ if (UNEXPECTED(object_init_ex(&tmp_soap, service->soap_class.ce) != SUCCESS)) {
+ php_output_discard();
+ _soap_server_exception(service, function, ZEND_THIS);
+ goto fail;
+ }
/* Call constructor */
if (service->soap_class.ce->constructor) {
diff --git a/ext/soap/tests/gh23447.phpt b/ext/soap/tests/gh23447.phpt
new file mode 100644
index 000000000000..16ecc4568ebd
--- /dev/null
+++ b/ext/soap/tests/gh23447.phpt
@@ -0,0 +1,28 @@
+--TEST--
+GH-23447 (Segfault when a class passed to SoapServer::setClass() fails to initialize)
+--EXTENSIONS--
+soap
+--CREDITS--
+Lu Maltsis (@lmaltsis)
+--FILE--
+<?php
+class foo {
+ private $broken = undefinedConstant;
+}
+
+$server = new SoapServer(null, ['uri' => 'http://testuri.org']);
+$server->setClass('foo');
+
+$server->handle(<<<'XML'
+<?xml version="1.0"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
+ <SOAP-ENV:Body><anything/></SOAP-ENV:Body>
+</SOAP-ENV:Envelope>
+XML);
+
+echo "ok\n";
+?>
+--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>Undefined constant "undefinedConstant"</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
+ok