]> granicus.if.org Git - php/commitdiff
Fix xml doc leak in soap
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 25 Jun 2019 14:57:09 +0000 (16:57 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 26 Jun 2019 09:43:11 +0000 (11:43 +0200)
ext/soap/soap.c

index a74aaf7d15207e57a1ffa006caab58e9e924e314..61f98e93251305aebd0016445f1874d018fad97b 100644 (file)
@@ -1485,7 +1485,7 @@ PHP_METHOD(SoapServer, handle)
        int soap_version, old_soap_version;
        sdlPtr old_sdl = NULL;
        soapServicePtr service;
-       xmlDocPtr doc_request=NULL, doc_return;
+       xmlDocPtr doc_request = NULL, doc_return = NULL;
        zval function_name, *params, *soap_obj, retval;
        char *fn_name, cont_len[30];
        int num_params = 0, size, i, call_status = 0;
@@ -1760,8 +1760,6 @@ PHP_METHOD(SoapServer, handle)
                }
        }
 
-       doc_return = NULL;
-
        /* Process soap headers */
        if (soap_headers != NULL) {
                soapHeader *header = soap_headers;
@@ -1913,8 +1911,6 @@ PHP_METHOD(SoapServer, handle)
                        sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8")-1, 1);
                }
 
-               xmlFreeDoc(doc_return);
-
                if (zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0)) {
                        sapi_add_header("Connection: close", sizeof("Connection: close")-1, 1);
                } else {
@@ -1936,6 +1932,10 @@ fail:
        SOAP_GLOBAL(typemap) = old_typemap;
        SOAP_GLOBAL(features) = old_features;
 
+       if (doc_return) {
+               xmlFreeDoc(doc_return);
+       }
+
        /* Free soap headers */
        zval_ptr_dtor(&retval);
        while (soap_headers != NULL) {