Skip to content

Commit aca2c73

Browse files
committed
Fix GH-19784: SoapServer memory leak
1 parent b8a9d79 commit aca2c73

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

ext/soap/soap.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,13 @@ PHP_METHOD(SoapServer, __construct)
880880
service->soap_functions.ft = zend_new_array(0);
881881

882882
if (wsdl) {
883-
service->sdl = get_sdl(ZEND_THIS, ZSTR_VAL(wsdl), cache_wsdl);
883+
zend_try {
884+
service->sdl = get_sdl(ZEND_THIS, ZSTR_VAL(wsdl), cache_wsdl);
885+
} zend_catch {
886+
xmlCharEncCloseFunc(service->encoding);
887+
service->encoding = NULL;
888+
zend_bailout();
889+
} zend_end_try();
884890
if (service->uri == NULL) {
885891
if (service->sdl->target_ns) {
886892
service->uri = estrdup(service->sdl->target_ns);

ext/soap/tests/bugs/gh19784.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
GH-19784 (SoapServer memory leak)
3+
--EXTENSIONS--
4+
soap
5+
--FILE--
6+
<?php
7+
$v_5256 = 'zpHOks6TzpTOlc6WzpfOmM6ZzprOm86czp3Ons6fzqDOoc6jzqTOpc6mzqfOqM6p';
8+
$v_5257 = base64_decode($v_5256,);
9+
$v_5238 = array('encoding' => $v_5257);
10+
new SoapServer('foobarbaz',$v_5238,);
11+
?>
12+
--EXPECT--
13+
<?xml version="1.0" encoding="UTF-8"?>
14+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>WSDL</faultcode><faultstring>SOAP-ERROR: Parsing WSDL: Couldn't load from 'foobarbaz' : failed to load "foobarbaz": No such file or directory
15+
</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>

0 commit comments

Comments
 (0)