Skip to content

Commit fab508f

Browse files
Merge branch 'PHP-8.6'
* PHP-8.6: ext/soap: fix leak when `load_wsdl_ex()` fails to load (#24066)
2 parents 459f8cb + bd334e6 commit fab508f

3 files changed

Lines changed: 31 additions & 1 deletion

File tree

‎ext/soap/php_sdl.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,12 @@ static void load_wsdl_ex(zval *this_ptr, char *struri, sdlCtx *ctx, bool include
361361
xmlAttrPtr tmp = get_attribute(trav->properties, "location");
362362
if (tmp) {
363363
xmlChar *uri = schema_location_construct_uri(tmp);
364-
load_wsdl_ex(this_ptr, (char*)uri, ctx, true);
364+
zend_try {
365+
load_wsdl_ex(this_ptr, (char*)uri, ctx, true);
366+
} zend_catch {
367+
xmlFree(uri);
368+
zend_bailout();
369+
} zend_end_try();
365370
xmlFree(uri);
366371
}
367372

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
load_wsdl_ex() leaks the import location if imported WSDL fails to load
3+
--EXTENSIONS--
4+
soap
5+
--INI--
6+
soap.wsdl_cache_enabled=0
7+
--FILE--
8+
<?php
9+
10+
try {
11+
$client = new SoapClient(__DIR__ . '/load_wsdl_ex-failure-leak.wsdl');
12+
} catch (SoapFault $e) {
13+
echo get_class($e) . ': ' . $e->getMessage() . "\n";
14+
}
15+
16+
?>
17+
--EXPECTF--
18+
SoapFault: SOAP-ERROR: Parsing WSDL: Couldn't load from '%sload_wsdl_ex-failure-leak-missing.wsdl' : %s
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<definitions
3+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
4+
xmlns="http://schemas.xmlsoap.org/wsdl/"
5+
>
6+
<import location="load_wsdl_ex-failure-leak-missing.wsdl"/>
7+
</definitions>

0 commit comments

Comments
 (0)