Skip to content

Commit eed7474

Browse files
committed
Merge branch 'PHP-8.3'
* PHP-8.3: Minor fix in `NEWS` alignment Fix bug #75306: Memleak in SoapClient
2 parents b7bf5e5 + f8433a5 commit eed7474

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

ext/soap/php_sdl.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3268,6 +3268,9 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, zend_long cache_wsdl)
32683268
tmp = Z_CLIENT_STREAM_CONTEXT_P(this_ptr);
32693269
if (Z_TYPE_P(tmp) == IS_RESOURCE) {
32703270
context = php_stream_context_from_zval(tmp, 0);
3271+
/* Share a reference with new_context down below.
3272+
* For new contexts, the reference is only in new_context so that doesn't need extra refcounting. */
3273+
GC_ADDREF(context->res);
32713274
}
32723275

32733276
tmp = Z_CLIENT_USER_AGENT_P(this_ptr);
@@ -3334,7 +3337,7 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, zend_long cache_wsdl)
33343337
}
33353338

33363339
if (context) {
3337-
php_stream_context_to_zval(context, &new_context);
3340+
ZVAL_RES(&new_context, context->res);
33383341
php_libxml_switch_context(&new_context, &orig_context);
33393342
}
33403343

ext/soap/tests/bug75306.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #75306 (Memleak in SoapClient)
3+
--EXTENSIONS--
4+
soap
5+
--FILE--
6+
<?php
7+
$options = array("cache_wsdl" => WSDL_CACHE_NONE);
8+
// Need a warm-up for globals
9+
for ($i = 0; $i < 10; $i++) {
10+
$client = new SoapClient("ext/soap/tests/test.wsdl", $options);
11+
}
12+
$usage = memory_get_usage();
13+
for ($i = 0; $i < 10; $i++) {
14+
$client = new SoapClient("ext/soap/tests/test.wsdl", $options);
15+
}
16+
$usage_delta = memory_get_usage() - $usage;
17+
var_dump($usage_delta);
18+
?>
19+
--EXPECT--
20+
int(0)

0 commit comments

Comments
 (0)