Module: kamailio
Branch: master
Commit: 6461b799ce64315b72b8e2f4f7e4617603330833
URL:
https://github.com/kamailio/kamailio/commit/6461b799ce64315b72b8e2f4f7e4617…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2015-06-05T11:41:21+02:00
pv: convert negative index to positive position for $branch(...)
- better access to branch structures
---
Modified: modules/pv/pv_branch.c
---
Diff:
https://github.com/kamailio/kamailio/commit/6461b799ce64315b72b8e2f4f7e4617…
Patch:
https://github.com/kamailio/kamailio/commit/6461b799ce64315b72b8e2f4f7e4617…
---
diff --git a/modules/pv/pv_branch.c b/modules/pv/pv_branch.c
index e35330a..34626b3 100644
--- a/modules/pv/pv_branch.c
+++ b/modules/pv/pv_branch.c
@@ -133,6 +133,16 @@ int pv_set_branchx_helper(sip_msg_t *msg, pv_param_t *param,
LM_ERR("invalid index\n");
return -1;
}
+ if(idx<0)
+ {
+ if((int)nr_branches + idx >= 0) {
+ idx += nr_branches;
+ } else {
+ LM_ERR("index too low: %d (%u)\n", idx, nr_branches);
+ return -1;
+ }
+ }
+ LM_DBG("managing branch index %d (%u)\n", idx, nr_branches);
br = get_sip_branch(idx);
}