Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion ext/soap/soap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
26 changes: 26 additions & 0 deletions ext/soap/tests/gh23447.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--TEST--
GH-23447 (Segfault when a class passed to SoapServer::setClass() fails to initialize)
--EXTENSIONS--
soap

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit adding proper CREDITS here

--FILE--
<?php
class foo {
private $broken = undefinedConstant;
}

$server = new SoapServer(null, array('uri' => 'http://testuri.org'));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: for arrays, the [] form is preferred.

$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
Loading