Skip to content

Commit 51bb9c2

Browse files
committed
Fix memory leak if calling SoapServer::setObject() twice
Closes GH-14380.
1 parent 6aa66e0 commit 51bb9c2

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ PHP NEWS
2929
- Soap:
3030
. Fixed bug #47925 (PHPClient can't decompress response). (nielsdos)
3131
. Fix missing error restore code. (nielsdos)
32+
. Fix memory leak if calling SoapServer::setObject() twice. (nielsdos)
3233

3334
- Sodium:
3435
. Fix memory leaks in ext/sodium on failure of some functions. (nielsdos)

ext/soap/soap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,7 @@ PHP_METHOD(SoapServer, setObject)
959959

960960
service->type = SOAP_OBJECT;
961961

962+
zval_ptr_dtor(&service->soap_object);
962963
ZVAL_OBJ_COPY(&service->soap_object, Z_OBJ_P(obj));
963964

964965
SOAP_SERVER_END_CODE();
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
SOAP Server: SoapServer::setObject twice
3+
--EXTENSIONS--
4+
soap
5+
--FILE--
6+
<?php
7+
$foo = new stdClass();
8+
$server = new SoapServer(null,array('uri'=>"http://testuri.org"));
9+
$server->setObject($foo);
10+
$server->setObject($foo);
11+
echo "Done\n";
12+
?>
13+
--EXPECT--
14+
Done

0 commit comments

Comments
 (0)