Skip to content

Commit 809a58b

Browse files
committed
Fix GH-16237: Segmentation fault when cloning SoapServer
Bisect points to 94ee4f9, however this only reveals the problem. Cloning an object on a lower branch and trying to call its methods crashes as well. Cloning the object shouldn't be possible in the first place because there's an engine constraint that when we have a new object handler we should also have a clone handler. This constraint is not fulfilled here. Closes GH-16245.
1 parent a3ff092 commit 809a58b

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ PHP NEWS
7070

7171
- SOAP:
7272
. Fixed bug #62900 (Wrong namespace on xsd import error message). (nielsdos)
73+
. Fixed bug GH-16237 (Segmentation fault when cloning SoapServer). (nielsdos)
7374

7475
- Standard:
7576
. Fixed bug GH-15613 (overflow on unpack call hex string repeater).

ext/soap/soap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ PHP_MINIT_FUNCTION(soap)
412412
memcpy(&soap_server_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
413413
soap_server_object_handlers.offset = XtOffsetOf(soap_server_object, std);
414414
soap_server_object_handlers.free_obj = soap_server_object_free;
415+
soap_server_object_handlers.clone_obj = NULL;
415416

416417
/* Register SoapFault class */
417418
soap_fault_class_entry = register_class_SoapFault(zend_ce_exception);

ext/soap/tests/bugs/gh16237.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
GH-16237 (Segmentation fault when cloning SoapServer)
3+
--EXTENSIONS--
4+
soap
5+
--FILE--
6+
<?php
7+
8+
$server = new SoapServer(null, ['uri'=>"http://testuri.org"]);
9+
try {
10+
clone $server;
11+
} catch (Error $e) {
12+
echo $e->getMessage(), "\n";
13+
}
14+
15+
?>
16+
--EXPECT--
17+
Trying to clone an uncloneable object of class SoapServer

0 commit comments

Comments
 (0)