On 17/02/2014 20:34, Juha Heinanen wrote:
Guillaume Bour writes:

Can't you directly apply my patch on 4.0 branch ?
i can if you send me all changes in one patch.

-- juha

Hi Juha, here it is

Regards,
Guillaume

diff --git a/kamailio-4.0.5.1/modules/utils/functions.c b/kamailio-4.0.5.1/modules/utils/functions.c
index aadfdd5..660050d 100644
--- a/kamailio-4.0.5.1/modules/utils/functions.c
+++ b/kamailio-4.0.5.1/modules/utils/functions.c
@@ -51,7 +51,7 @@ size_t write_function( void *ptr, size_t size, size_t nmemb, void *stream)
     /* Allocate memory and copy */
     char* data;
 
-    data = (char*)malloc((size* nmemb) + 1);
+    data = (char*)pkg_malloc((size* nmemb) + 1);
     if (data == NULL) {
 	LM_ERR("cannot allocate memory for stream\n");
 	return CURLE_WRITE_ERROR;
@@ -76,7 +76,7 @@ int http_query(struct sip_msg* _m, char* _url, char* _dst)
     CURLcode res;  
     str value;
     char *url, *at;
-    char* stream;
+    char* stream = NULL;
     long stat;
     pv_spec_t *dst;
     pv_value_t val;
@@ -112,10 +112,12 @@ int http_query(struct sip_msg* _m, char* _url, char* _dst)
 
     res = curl_easy_perform(curl);  
     pkg_free(url);
-    curl_easy_cleanup(curl);
 
     if (res != CURLE_OK) {
 	LM_ERR("failed to perform curl\n");
+	curl_easy_cleanup(curl);
+	if(stream)
+		pkg_free(stream);
 	return -1;
     }
 
@@ -131,11 +133,13 @@ int http_query(struct sip_msg* _m, char* _url, char* _dst)
 	}
 	val.rs.s = stream;
 	val.rs.len = at - stream;
-	LM_DBG("http)query result: %.*s\n", val.rs.len, val.rs.s);
+	LM_DBG("http_query result: %.*s\n", val.rs.len, val.rs.s);
 	val.flags = PV_VAL_STR;
 	dst = (pv_spec_t *)_dst;
 	dst->setf(_m, &dst->pvp, (int)EQ_T, &val);
     }
 	
+    curl_easy_cleanup(curl);
+    pkg_free(stream);
     return stat;
 }
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

Reply via email to