From 59fdff842c25ab887668913937a7cf7609f32804 Mon Sep 17 00:00:00 2001 From: Lazizbek Ergashev Date: Tue, 25 Aug 2026 15:17:39 +0500 Subject: [PATCH 1/2] Fix GH-23447: segfault when the SoapServer class fails to initialize --- NEWS | 4 ++++ ext/soap/soap.c | 6 +++++- ext/soap/tests/gh23447.phpt | 26 ++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 ext/soap/tests/gh23447.phpt diff --git a/NEWS b/NEWS index 5607f31081b8..31ebb08f01f3 100644 --- a/NEWS +++ b/NEWS @@ -45,6 +45,10 @@ PHP NEWS . Fixed a leak when a persistent connection failed a liveness check with no other live PDO handle. (iliaal) +- SOAP: + . Fixed bug GH-23447 (Segfault when a class passed to SoapServer::setClass() + fails to initialize). (Lazizbek Ergashev) + - Standard: . Fixed a memory leak in array_merge_recursive() when the recursive merge of an object converted to an array fails. (David Carlier) diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 3d5536ef8628..4703c7779305 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -1478,7 +1478,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..37ed63f323fc --- /dev/null +++ b/ext/soap/tests/gh23447.phpt @@ -0,0 +1,26 @@ +--TEST-- +GH-23447 (segfault on soap server handler when it contains undefined constant) +--EXTENSIONS-- +soap +--FILE-- + 'http://testuri.org')); +$server->setClass('foo'); + +$server->handle(<<<'XML' + + + + +XML); + +echo "ok\n"; +?> +--EXPECT-- + +SOAP-ENV:ServerUndefined constant "undefinedConstant" +ok From 35008cfca8382abfa9e690591bbc7a01f3e19de2 Mon Sep 17 00:00:00 2001 From: Lazizbek Ergashev Date: Tue, 25 Aug 2026 16:14:23 +0500 Subject: [PATCH 2/2] ext/soap: describe the GH-23447 test the same way NEWS does --- ext/soap/tests/gh23447.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/soap/tests/gh23447.phpt b/ext/soap/tests/gh23447.phpt index 37ed63f323fc..4b63b1cde947 100644 --- a/ext/soap/tests/gh23447.phpt +++ b/ext/soap/tests/gh23447.phpt @@ -1,5 +1,5 @@ --TEST-- -GH-23447 (segfault on soap server handler when it contains undefined constant) +GH-23447 (Segfault when a class passed to SoapServer::setClass() fails to initialize) --EXTENSIONS-- soap --FILE--