Module: kamailio Branch: 4.3 Commit: e5452003a5219e50d26baa72e773fa1690b45a3d URL: https://github.com/kamailio/kamailio/commit/e5452003a5219e50d26baa72e773fa16...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2015-06-09T10:33:48+02:00
pv: convert negative index to positive position for $branch(...)
- better access to branch structures
(cherry picked from commit 6461b799ce64315b72b8e2f4f7e4617603330833)
---
Modified: modules/pv/pv_branch.c
---
Diff: https://github.com/kamailio/kamailio/commit/e5452003a5219e50d26baa72e773fa16... Patch: https://github.com/kamailio/kamailio/commit/e5452003a5219e50d26baa72e773fa16...
---
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); }