Module: kamailio
Branch: master
Commit: 9ce38204d8a59e5d83cc50a2c809d1306346f9b7
URL:
https://github.com/kamailio/kamailio/commit/9ce38204d8a59e5d83cc50a2c809d13…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-08-07T14:54:00+02:00
http_client: proper free for curl params in case of failover connection
---
Modified: src/modules/http_client/functions.c
---
Diff:
https://github.com/kamailio/kamailio/commit/9ce38204d8a59e5d83cc50a2c809d13…
Patch:
https://github.com/kamailio/kamailio/commit/9ce38204d8a59e5d83cc50a2c809d13…
---
diff --git a/src/modules/http_client/functions.c b/src/modules/http_client/functions.c
index 1bdae25df7..ca26998606 100644
--- a/src/modules/http_client/functions.c
+++ b/src/modules/http_client/functions.c
@@ -464,12 +464,15 @@ int curl_get_redirect(struct sip_msg* _m, const str *connection,
str* result)
/*! Run a query based on a connection definition */
-int curl_con_query_url_f(struct sip_msg* _m, const str *connection, const str* url, str*
result, const char *contenttype, const str* post, int failover)
+int curl_con_query_url_f(struct sip_msg* _m, const str *connection,
+ const str* url, str* result, const char *contenttype,
+ const str* post, int failover)
{
curl_con_t *conn = NULL;
curl_con_pkg_t *pconn = NULL;
char *urlbuf = NULL;
char *postdata = NULL;
+ char *failovercon = NULL;
curl_query_t query_params;
unsigned int maxdatasize = default_maxdatasize;
@@ -495,7 +498,6 @@ int curl_con_query_url_f(struct sip_msg* _m, const str *connection,
const str* u
LM_DBG("******** CURL Connection found %.*s\n", connection->len,
connection->s);
maxdatasize = conn->maxdatasize;
-
if (url && (url->len > 0) && (url->s != NULL)) {
int url_len = conn->schema.len + 3 + conn->url.len + 1 + url->len + 1;
urlbuf = pkg_malloc(url_len);
@@ -552,7 +554,10 @@ int curl_con_query_url_f(struct sip_msg* _m, const str *connection,
const str* u
query_params.oneline = 0;
query_params.maxdatasize = maxdatasize;
query_params.http_proxy_port = conn->http_proxy_port;
- query_params.failovercon = conn->failover.s ? as_asciiz(&conn->failover) :
NULL;
+ if(conn->failover.s) {
+ failovercon = as_asciiz(&conn->failover);
+ }
+ query_params.failovercon = failovercon;
query_params.pconn = pconn;
if (conn->http_proxy) {
query_params.http_proxy = conn->http_proxy;
@@ -567,14 +572,19 @@ int curl_con_query_url_f(struct sip_msg* _m, const str *connection,
const str* u
int counter = failover + 1;
if (counter >= 2) {
LM_DBG("**** No more failovers - returning failure\n");
- return (res - 1000);
+ res = (res - 1000);
+ goto error;
}
/* Time for failover */
- return curl_con_query_url_f(_m, &conn->failover, url, result, contenttype, post,
counter);
+ res = curl_con_query_url_f(_m, &conn->failover, url, result,
+ contenttype, post, counter);
}
- LM_DBG("***** #### ***** CURL DONE : %s \n", urlbuf);
+ LM_DBG("***** #### ***** CURL DONE: %s (%d)\n", urlbuf, res);
error:
+ if (failovercon != NULL) {
+ pkg_free(failovercon);
+ }
if (urlbuf != NULL) {
pkg_free(urlbuf);
}