From aca2c73d0e2ef1a68fea9cd574c8bcf650251155 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Fri, 12 Sep 2025 21:45:46 +0200 Subject: [PATCH 1/4] Fix GH-19784: SoapServer memory leak --- ext/soap/soap.c | 8 +++++++- ext/soap/tests/bugs/gh19784.phpt | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 ext/soap/tests/bugs/gh19784.phpt diff --git a/ext/soap/soap.c b/ext/soap/soap.c index fc51e32658f3a..4a4fa4f4e626b 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -880,7 +880,13 @@ PHP_METHOD(SoapServer, __construct) service->soap_functions.ft = zend_new_array(0); if (wsdl) { - service->sdl = get_sdl(ZEND_THIS, ZSTR_VAL(wsdl), cache_wsdl); + zend_try { + service->sdl = get_sdl(ZEND_THIS, ZSTR_VAL(wsdl), cache_wsdl); + } zend_catch { + xmlCharEncCloseFunc(service->encoding); + service->encoding = NULL; + zend_bailout(); + } zend_end_try(); if (service->uri == NULL) { if (service->sdl->target_ns) { service->uri = estrdup(service->sdl->target_ns); diff --git a/ext/soap/tests/bugs/gh19784.phpt b/ext/soap/tests/bugs/gh19784.phpt new file mode 100644 index 0000000000000..fcff28909e463 --- /dev/null +++ b/ext/soap/tests/bugs/gh19784.phpt @@ -0,0 +1,15 @@ +--TEST-- +GH-19784 (SoapServer memory leak) +--EXTENSIONS-- +soap +--FILE-- + $v_5257); +new SoapServer('foobarbaz',$v_5238,); +?> +--EXPECT-- + +WSDLSOAP-ERROR: Parsing WSDL: Couldn't load from 'foobarbaz' : failed to load "foobarbaz": No such file or directory + From 76c1c8b61a95d42d74e16180436900b5fb8659aa Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Fri, 12 Sep 2025 22:07:38 +0200 Subject: [PATCH 2/4] Adjust error for older libxml --- ext/soap/tests/bugs/gh19784.phpt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/soap/tests/bugs/gh19784.phpt b/ext/soap/tests/bugs/gh19784.phpt index fcff28909e463..0435ec51c21f6 100644 --- a/ext/soap/tests/bugs/gh19784.phpt +++ b/ext/soap/tests/bugs/gh19784.phpt @@ -9,7 +9,7 @@ $v_5257 = base64_decode($v_5256,); $v_5238 = array('encoding' => $v_5257); new SoapServer('foobarbaz',$v_5238,); ?> ---EXPECT-- +--EXPECTF-- -WSDLSOAP-ERROR: Parsing WSDL: Couldn't load from 'foobarbaz' : failed to load "foobarbaz": No such file or directory +WSDLSOAP-ERROR: Parsing WSDL: Couldn't load from 'foobarbaz'%s From 8c66c4c1e3d2548bac604499c121a0e4959a3cd4 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Fri, 12 Sep 2025 22:33:55 +0200 Subject: [PATCH 3/4] even more for libxml differences --- ext/soap/tests/bugs/gh19784.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/soap/tests/bugs/gh19784.phpt b/ext/soap/tests/bugs/gh19784.phpt index 0435ec51c21f6..43b9b1d96af45 100644 --- a/ext/soap/tests/bugs/gh19784.phpt +++ b/ext/soap/tests/bugs/gh19784.phpt @@ -11,5 +11,5 @@ new SoapServer('foobarbaz',$v_5238,); ?> --EXPECTF-- -WSDLSOAP-ERROR: Parsing WSDL: Couldn't load from 'foobarbaz'%s +%s%a From eb9e8b0e0ae08098325aa5a60f39e944bc7fea01 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Fri, 12 Sep 2025 22:54:36 +0200 Subject: [PATCH 4/4] fuck this shit --- ext/soap/tests/bugs/gh19784.phpt | 1 - 1 file changed, 1 deletion(-) diff --git a/ext/soap/tests/bugs/gh19784.phpt b/ext/soap/tests/bugs/gh19784.phpt index 43b9b1d96af45..1f718e74c4598 100644 --- a/ext/soap/tests/bugs/gh19784.phpt +++ b/ext/soap/tests/bugs/gh19784.phpt @@ -12,4 +12,3 @@ new SoapServer('foobarbaz',$v_5238,); --EXPECTF-- %s%a -