Browse code

pv: free escaped value for {val.json} transformations

Daniel-Constantin Mierla authored on 07/12/2021 08:27:17
Showing 1 changed files
... ...
@@ -2580,6 +2580,7 @@ int tr_eval_val(struct sip_msg *msg, tr_param_t *tp, int subtype,
2580 2580
 					return 0;
2581 2581
 				}
2582 2582
 				if(sv.len >= TR_BUFFER_SIZE - 1) {
2583
+					free(sv.s);
2583 2584
 					LM_ERR("escaped value is too long\n");
2584 2585
 					return -1;
2585 2586
 				}
... ...
@@ -2588,6 +2589,7 @@ int tr_eval_val(struct sip_msg *msg, tr_param_t *tp, int subtype,
2588 2589
 				_tr_buffer[sv.len] = '\0';
2589 2590
 				val->rs.s = _tr_buffer;
2590 2591
 				val->rs.len = sv.len;
2592
+				free(sv.s);
2591 2593
 			}
2592 2594
 			break;
2593 2595
 		case TR_VAL_JSONQE:
... ...
@@ -2601,7 +2603,8 @@ int tr_eval_val(struct sip_msg *msg, tr_param_t *tp, int subtype,
2601 2603
 				val->rs.len = 2;
2602 2604
 				val->flags = PV_VAL_STR;
2603 2605
 			} else if(val->flags&PV_TYPE_INT) {
2604
-				break;
2606
+				/* no change needed */
2607
+				return 0;
2605 2608
 			} else if(val->flags&PV_VAL_STR) {
2606 2609
 				ksr_str_json_escape(&val->rs, &sv, &emode);
2607 2610
 				if(sv.s==NULL) {
... ...
@@ -2613,6 +2616,7 @@ int tr_eval_val(struct sip_msg *msg, tr_param_t *tp, int subtype,
2613 2616
 					return 0;
2614 2617
 				}
2615 2618
 				if(sv.len >= TR_BUFFER_SIZE - 3) {
2619
+					free(sv.s);
2616 2620
 					LM_ERR("escaped value is too long\n");
2617 2621
 					return -1;
2618 2622
 				}
... ...
@@ -2623,6 +2627,7 @@ int tr_eval_val(struct sip_msg *msg, tr_param_t *tp, int subtype,
2623 2627
 				_tr_buffer[sv.len + 2] = '\0';
2624 2628
 				val->rs.s = _tr_buffer;
2625 2629
 				val->rs.len = sv.len + 2;
2630
+				free(sv.s);
2626 2631
 			}
2627 2632
 			break;
2628 2633