Module: kamailio
Branch: master
Commit: eaec3aaac227eb4a8c48f93b45565d15d4a0a991
URL:
https://github.com/kamailio/kamailio/commit/eaec3aaac227eb4a8c48f93b45565d1…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-10-07T09:21:20+02:00
pv: {line.count} - count last line without \n
---
Modified: src/modules/pv/pv_trans.c
---
Diff:
https://github.com/kamailio/kamailio/commit/eaec3aaac227eb4a8c48f93b45565d1…
Patch:
https://github.com/kamailio/kamailio/commit/eaec3aaac227eb4a8c48f93b45565d1…
---
diff --git a/src/modules/pv/pv_trans.c b/src/modules/pv/pv_trans.c
index b63ad022f8..330c70cb6f 100644
--- a/src/modules/pv/pv_trans.c
+++ b/src/modules/pv/pv_trans.c
@@ -2435,19 +2435,22 @@ int tr_eval_line(struct sip_msg *msg, tr_param_t *tp, int
subtype,
break;
case TR_LINE_COUNT:
- n=0;
- for(i=0; i<val->rs.len; i++)
- if(val->rs.s[i]=='\n')
+ n = 0;
+ if(val->rs.len>0) {
+ for(i=0; i<val->rs.len; i++) {
+ if(val->rs.s[i]=='\n') {
+ n++;
+ }
+ }
+ if(val->rs.s[val->rs.len-1]!='\n') {
n++;
- if(n==0 && val->rs.len>0)
- n = 1;
+ }
+ }
val->flags = PV_TYPE_INT|PV_VAL_INT|PV_VAL_STR;
val->ri = n;
val->rs.s = int2str(val->ri, &val->rs.len);
break;
- break;
-
default:
LM_ERR("unknown subtype %d\n",
subtype);