com php-src: Fixed memory leaks: ext/soap/soap.c
| From: | Dmitry Stogov | Date: | Tue, 10 Mar 2015 22:28:13 +0000 |
| Subject: | com php-src: Fixed memory leaks: ext/soap/soap.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-85452@lists.php.net to get a copy of this message | ||
Commit: 026b0adc50f1c7683e1446bdbc8fbf64f3daeddd
Author: Dmitry Stogov <dmitry@zend.com> Wed, 11 Mar 2015 01:28:13 +0300
Parents: 48deb1cd9427c725790b074e05ccf1c9962e9dc9
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=026b0adc50f1c7683e1446bdbc8fbf64f3daeddd
Log:
Fixed memory leaks
Changed paths:
M ext/soap/soap.c
Diff:
diff --git a/ext/soap/soap.c b/ext/soap/soap.c
index 3e3f0d9..d411345 100644
--- a/ext/soap/soap.c
+++ b/ext/soap/soap.c
@@ -2554,6 +2554,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char
*act
zval params[5];
zval *trace;
zval *fault;
+ int _bailout = 0;
ZVAL_NULL(response);
@@ -2563,38 +2564,42 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char
*act
return FALSE;
}
- if ((trace = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "trace",
sizeof("trace")-1)) != NULL &&
- (Z_TYPE_P(trace) == IS_TRUE || (Z_TYPE_P(trace) == IS_LONG && Z_LVAL_P(trace) != 0)))
{
- add_property_stringl(this_ptr, "__last_request", buf, buf_size);
- }
+ zend_try {
+ if ((trace = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "trace",
sizeof("trace")-1)) != NULL &&
+ (Z_TYPE_P(trace) == IS_TRUE || (Z_TYPE_P(trace) == IS_LONG && Z_LVAL_P(trace) != 0)))
{
+ add_property_stringl(this_ptr, "__last_request", buf, buf_size);
+ }
- ZVAL_STRINGL(&func,"__doRequest",sizeof("__doRequest")-1);
- ZVAL_STRINGL(¶ms[0], buf, buf_size);
- if (location == NULL) {
- ZVAL_NULL(¶ms[1]);
- } else {
- ZVAL_STRING(¶ms[1], location);
- }
- if (action == NULL) {
- ZVAL_NULL(¶ms[2]);
- } else {
- ZVAL_STRING(¶ms[2], action);
- }
- ZVAL_LONG(¶ms[3], version);
- ZVAL_LONG(¶ms[4], one_way);
+ ZVAL_STRINGL(&func,"__doRequest",sizeof("__doRequest")-1);
+ ZVAL_STRINGL(¶ms[0], buf, buf_size);
+ if (location == NULL) {
+ ZVAL_NULL(¶ms[1]);
+ } else {
+ ZVAL_STRING(¶ms[1], location);
+ }
+ if (action == NULL) {
+ ZVAL_NULL(¶ms[2]);
+ } else {
+ ZVAL_STRING(¶ms[2], action);
+ }
+ ZVAL_LONG(¶ms[3], version);
+ ZVAL_LONG(¶ms[4], one_way);
- if (call_user_function(NULL, this_ptr, &func, response, 5, params) != SUCCESS) {
- add_soap_fault(this_ptr, "Client", "SoapClient::__doRequest() failed", NULL,
NULL);
- ret = FALSE;
- } else if (Z_TYPE_P(response) != IS_STRING) {
- if ((fault = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "__soap_fault",
sizeof("__soap_fault")-1)) == NULL) {
- add_soap_fault(this_ptr, "Client", "SoapClient::__doRequest() returned non string
value", NULL, NULL);
+ if (call_user_function(NULL, this_ptr, &func, response, 5, params) != SUCCESS) {
+ add_soap_fault(this_ptr, "Client", "SoapClient::__doRequest() failed", NULL,
NULL);
+ ret = FALSE;
+ } else if (Z_TYPE_P(response) != IS_STRING) {
+ if ((fault = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "__soap_fault",
sizeof("__soap_fault")-1)) == NULL) {
+ add_soap_fault(this_ptr, "Client", "SoapClient::__doRequest() returned non
string value", NULL, NULL);
+ }
+ ret = FALSE;
+ } else if ((trace = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "trace",
sizeof("trace")-1)) != NULL &&
+ (Z_TYPE_P(trace) == IS_TRUE || (Z_TYPE_P(trace) == IS_LONG && Z_LVAL_P(trace) != 0)))
{
+ add_property_str(this_ptr, "__last_response", zend_string_copy(Z_STR_P(response)));
}
- ret = FALSE;
- } else if ((trace = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "trace",
sizeof("trace")-1)) != NULL &&
- (Z_TYPE_P(trace) == IS_TRUE || (Z_TYPE_P(trace) == IS_LONG && Z_LVAL_P(trace) != 0)))
{
- add_property_str(this_ptr, "__last_response", zend_string_copy(Z_STR_P(response)));
- }
+ } zend_catch {
+ _bailout = 1;
+ } zend_end_try();
zval_ptr_dtor(&func);
zval_ptr_dtor(¶ms[4]);
zval_ptr_dtor(¶ms[3]);
@@ -2602,10 +2607,13 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char
*act
zval_ptr_dtor(¶ms[1]);
zval_ptr_dtor(¶ms[0]);
xmlFree(buf);
+ if (_bailout) {
+ zend_bailout();
+ }
if (ret && (fault = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "__soap_fault",
sizeof("__soap_fault")-1)) != NULL) {
- return FALSE;
+ ret = FALSE;
}
- return ret;
+ return ret;
}
static void do_soap_call(zend_execute_data *execute_data,
@@ -2635,6 +2643,7 @@ static void do_soap_call(zend_execute_data *execute_data,
HashTable *old_class_map;
int old_features;
HashTable *old_typemap, *typemap = NULL;
+ smart_str action = {0};
SOAP_CLIENT_BEGIN_CODE();
@@ -2719,6 +2728,7 @@ static void do_soap_call(zend_execute_data *execute_data,
}
xmlFreeDoc(request);
+ request = NULL;
if (ret && Z_TYPE(response) == IS_STRING) {
encode_reset_ns();
@@ -2739,7 +2749,6 @@ static void do_soap_call(zend_execute_data *execute_data,
}
} else {
zval *uri;
- smart_str action = {0};
if ((uri = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "uri",
sizeof("uri")-1)) == NULL || Z_TYPE_P(uri) != IS_STRING) {
add_soap_fault(this_ptr, "Client", "Error finding \"uri\"
property", NULL, NULL);
@@ -2764,6 +2773,7 @@ static void do_soap_call(zend_execute_data *execute_data,
smart_str_free(&action);
xmlFreeDoc(request);
+ request = NULL;
if (ret && Z_TYPE(response) == IS_STRING) {
encode_reset_ns();
@@ -2812,6 +2822,10 @@ static void do_soap_call(zend_execute_data *execute_data,
SOAP_GLOBAL(encoding) = old_encoding;
SOAP_GLOBAL(sdl) = old_sdl;
if (_bailout) {
+ smart_str_free(&action);
+ if (request) {
+ xmlFreeDoc(request);
+ }
_bailout = 0;
zend_bailout();
}