From: Liviu Chircu <liviu@opensips.org>
Date: Fri, 15 Jul 2016 16:21:35 +0300
Subject: [PATCH] rest_client: Fix incorrect trim operation
(cherry picked from commit d8bf10da34152612e7835a64cedbb7593b8fc57b)
Conflicts:
modules/rest_client/rest_methods.c
diff --git a/modules/rest_client/rest_methods.c b/modules/rest_client/rest_methods.c
index c2763b0..d670365 100644
--- a/modules/rest_client/rest_methods.c
+++ b/modules/rest_client/rest_methods.c
@@ -59,7 +59,7 @@ int rest_get_method(struct sip_msg *msg, char *url,
long http_rc;
pv_value_t pv_val;
str st = { print_buff, 0 };
- str body = { 0, 0 };
+ str body = { NULL, 0 }, tbody;
handle = curl_easy_init();
if (!handle) {
@@ -114,10 +114,11 @@ int rest_get_method(struct sip_msg *msg, char *url,
goto error;
}
- trim(&body);
+ tbody = body;
+ trim(&tbody);
pv_val.flags = PV_VAL_STR;
- pv_val.rs = body;
+ pv_val.rs = tbody;
if (pv_set_value(msg, body_pv, 0, &pv_val) != 0) {
LM_ERR("Set body pv value failed!\n");
@@ -163,7 +164,7 @@ int rest_post_method(struct sip_msg *msg, char *url, char *ctype, char *body,
long http_rc;
struct curl_slist *list = NULL;
str st = { print_buff, 0 };
- str res_body = { 0, 0 };
+ str res_body = { NULL, 0 }, tbody;
pv_value_t pv_val;
handle = curl_easy_init();
@@ -229,10 +230,11 @@ int rest_post_method(struct sip_msg *msg, char *url, char *ctype, char *body,
goto error;
}
- trim(&res_body);
+ tbody = res_body;
+ trim(&tbody);
pv_val.flags = PV_VAL_STR;
- pv_val.rs = res_body;
+ pv_val.rs = tbody;
if (pv_set_value(msg, body_pv, 0, &pv_val) != 0) {
LM_ERR("Set body pv value failed!\n");