Skip to content
Closed
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
5 changes: 4 additions & 1 deletion ext/soap/php_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3243,6 +3243,9 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, zend_long cache_wsdl)
tmp = Z_CLIENT_STREAM_CONTEXT_P(this_ptr);
if (Z_TYPE_P(tmp) == IS_RESOURCE) {
context = php_stream_context_from_zval(tmp, 0);
/* Share a reference with new_context down below.
* For new contexts, the reference is only in new_context so that doesn't need extra refcounting. */
GC_ADDREF(context->res);
}

tmp = Z_CLIENT_USER_AGENT_P(this_ptr);
Expand Down Expand Up @@ -3311,7 +3314,7 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, zend_long cache_wsdl)
}

if (context) {
php_stream_context_to_zval(context, &new_context);
ZVAL_RES(&new_context, context->res);
php_libxml_switch_context(&new_context, &orig_context);
}

Expand Down
20 changes: 20 additions & 0 deletions ext/soap/tests/bug75306.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
Bug #75306 (Memleak in SoapClient)
--EXTENSIONS--
soap
--FILE--
<?php
$options = array("cache_wsdl" => WSDL_CACHE_NONE);
// Need a warm-up for globals
for ($i = 0; $i < 10; $i++) {
$client = new SoapClient("ext/soap/tests/test.wsdl", $options);
}
$usage = memory_get_usage();
for ($i = 0; $i < 10; $i++) {
$client = new SoapClient("ext/soap/tests/test.wsdl", $options);
}
$usage_delta = memory_get_usage() - $usage;
var_dump($usage_delta);
?>
--EXPECT--
int(0)