@@ -1643,7 +1643,15 @@ PHP_METHOD(SoapServer, handle)
1643
1643
old_features = SOAP_GLOBAL (features );
1644
1644
SOAP_GLOBAL (features ) = service -> features ;
1645
1645
old_soap_version = SOAP_GLOBAL (soap_version );
1646
- function = deserialize_function_call (service -> sdl , doc_request , service -> actor , & function_name , & num_params , & params , & soap_version , & soap_headers );
1646
+
1647
+ zend_try {
1648
+ function = deserialize_function_call (service -> sdl , doc_request , service -> actor , & function_name , & num_params , & params , & soap_version , & soap_headers );
1649
+ } zend_catch {
1650
+ /* Avoid leaking persistent memory */
1651
+ xmlFreeDoc (doc_request );
1652
+ zend_bailout ();
1653
+ } zend_end_try ();
1654
+
1647
1655
xmlFreeDoc (doc_request );
1648
1656
1649
1657
if (EG (exception )) {
@@ -3821,6 +3829,8 @@ static xmlDocPtr serialize_response_call(sdlFunctionPtr function, char *function
3821
3829
encode_reset_ns ();
3822
3830
3823
3831
doc = xmlNewDoc (BAD_CAST ("1.0" ));
3832
+ zend_try {
3833
+
3824
3834
doc -> charset = XML_CHAR_ENCODING_UTF8 ;
3825
3835
doc -> encoding = xmlCharStrdup ("UTF-8" );
3826
3836
@@ -4162,6 +4172,12 @@ static xmlDocPtr serialize_response_call(sdlFunctionPtr function, char *function
4162
4172
4163
4173
encode_finish ();
4164
4174
4175
+ } zend_catch {
4176
+ /* Avoid persistent memory leak. */
4177
+ xmlFreeDoc (doc );
4178
+ zend_bailout ();
4179
+ } zend_end_try ();
4180
+
4165
4181
if (function && function -> responseName == NULL &&
4166
4182
body -> children == NULL && head == NULL ) {
4167
4183
xmlFreeDoc (doc );
@@ -4183,6 +4199,8 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
4183
4199
encode_reset_ns ();
4184
4200
4185
4201
doc = xmlNewDoc (BAD_CAST ("1.0" ));
4202
+ zend_try {
4203
+
4186
4204
doc -> encoding = xmlCharStrdup ("UTF-8" );
4187
4205
doc -> charset = XML_CHAR_ENCODING_UTF8 ;
4188
4206
if (version == SOAP_1_1 ) {
@@ -4222,7 +4240,7 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
4222
4240
}
4223
4241
} else {
4224
4242
if ((zstyle = zend_hash_str_find (Z_OBJPROP_P (this_ptr ), "style" , sizeof ("style" )- 1 )) != NULL &&
4225
- Z_TYPE_P (zstyle ) == IS_LONG ) {
4243
+ Z_TYPE_P (zstyle ) == IS_LONG ) {
4226
4244
style = Z_LVAL_P (zstyle );
4227
4245
} else {
4228
4246
style = SOAP_RPC ;
@@ -4245,7 +4263,7 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
4245
4263
}
4246
4264
4247
4265
if ((zuse = zend_hash_str_find (Z_OBJPROP_P (this_ptr ), "use" , sizeof ("use" )- 1 )) != NULL &&
4248
- Z_TYPE_P (zuse ) == IS_LONG && Z_LVAL_P (zuse ) == SOAP_LITERAL ) {
4266
+ Z_TYPE_P (zuse ) == IS_LONG && Z_LVAL_P (zuse ) == SOAP_LITERAL ) {
4249
4267
use = SOAP_LITERAL ;
4250
4268
} else {
4251
4269
use = SOAP_ENCODED ;
@@ -4307,9 +4325,9 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
4307
4325
4308
4326
ht = Z_OBJPROP_P (header );
4309
4327
if ((name = zend_hash_str_find (ht , "name" , sizeof ("name" )- 1 )) != NULL &&
4310
- Z_TYPE_P (name ) == IS_STRING &&
4311
- (ns = zend_hash_str_find (ht , "namespace" , sizeof ("namespace" )- 1 )) != NULL &&
4312
- Z_TYPE_P (ns ) == IS_STRING ) {
4328
+ Z_TYPE_P (name ) == IS_STRING &&
4329
+ (ns = zend_hash_str_find (ht , "namespace" , sizeof ("namespace" )- 1 )) != NULL &&
4330
+ Z_TYPE_P (ns ) == IS_STRING ) {
4313
4331
xmlNodePtr h ;
4314
4332
xmlNsPtr nsptr ;
4315
4333
int hdr_use = SOAP_LITERAL ;
@@ -4362,6 +4380,12 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
4362
4380
4363
4381
encode_finish ();
4364
4382
4383
+ } zend_catch {
4384
+ /* Avoid persistent memory leak. */
4385
+ xmlFreeDoc (doc );
4386
+ zend_bailout ();
4387
+ } zend_end_try ();
4388
+
4365
4389
return doc ;
4366
4390
}
4367
4391
/* }}} */
0 commit comments