Module: kamailio
Branch: master
Commit: 7556fbfa38ac4dad00494944dd02fc60f65cfcb5
URL:
https://github.com/kamailio/kamailio/commit/7556fbfa38ac4dad00494944dd02fc6…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-12-07T09:27:44+01:00
pv: free escaped value for {val.json} transformations
---
Modified: src/modules/pv/pv_trans.c
---
Diff:
https://github.com/kamailio/kamailio/commit/7556fbfa38ac4dad00494944dd02fc6…
Patch:
https://github.com/kamailio/kamailio/commit/7556fbfa38ac4dad00494944dd02fc6…
---
diff --git a/src/modules/pv/pv_trans.c b/src/modules/pv/pv_trans.c
index 5d7e0d32b3..5f45fa8e66 100644
--- a/src/modules/pv/pv_trans.c
+++ b/src/modules/pv/pv_trans.c
@@ -2580,6 +2580,7 @@ int tr_eval_val(struct sip_msg *msg, tr_param_t *tp, int subtype,
return 0;
}
if(sv.len >= TR_BUFFER_SIZE - 1) {
+ free(sv.s);
LM_ERR("escaped value is too long\n");
return -1;
}
@@ -2588,6 +2589,7 @@ int tr_eval_val(struct sip_msg *msg, tr_param_t *tp, int subtype,
_tr_buffer[sv.len] = '\0';
val->rs.s = _tr_buffer;
val->rs.len = sv.len;
+ free(sv.s);
}
break;
case TR_VAL_JSONQE:
@@ -2601,7 +2603,8 @@ int tr_eval_val(struct sip_msg *msg, tr_param_t *tp, int subtype,
val->rs.len = 2;
val->flags = PV_VAL_STR;
} else if(val->flags&PV_TYPE_INT) {
- break;
+ /* no change needed */
+ return 0;
} else if(val->flags&PV_VAL_STR) {
ksr_str_json_escape(&val->rs, &sv, &emode);
if(sv.s==NULL) {
@@ -2613,6 +2616,7 @@ int tr_eval_val(struct sip_msg *msg, tr_param_t *tp, int subtype,
return 0;
}
if(sv.len >= TR_BUFFER_SIZE - 3) {
+ free(sv.s);
LM_ERR("escaped value is too long\n");
return -1;
}
@@ -2623,6 +2627,7 @@ int tr_eval_val(struct sip_msg *msg, tr_param_t *tp, int subtype,
_tr_buffer[sv.len + 2] = '\0';
val->rs.s = _tr_buffer;
val->rs.len = sv.len + 2;
+ free(sv.s);
}
break;