Module: kamailio Branch: master Commit: dd56c2821b2f0f7f47137b7875d90f0a6d421e35 URL: https://github.com/kamailio/kamailio/commit/dd56c2821b2f0f7f47137b7875d90f0a...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2015-04-26T21:58:33+02:00
pv: initialize sbranch via function and check return value
- reported by Anthony Messina, GH#141
---
Modified: modules/pv/pv.c Modified: modules/pv/pv_branch.c Modified: modules/pv/pv_branch.h
---
Diff: https://github.com/kamailio/kamailio/commit/dd56c2821b2f0f7f47137b7875d90f0a... Patch: https://github.com/kamailio/kamailio/commit/dd56c2821b2f0f7f47137b7875d90f0a...
---
diff --git a/modules/pv/pv.c b/modules/pv/pv.c index e0897b0..11d899a 100644 --- a/modules/pv/pv.c +++ b/modules/pv/pv.c @@ -541,10 +541,11 @@ static int mod_init(void) return -1; } if(pv_init_rpc()!=0) - { - LM_ERR("failed to register RPC commands\n"); - return -1; - } + { + LM_ERR("failed to register RPC commands\n"); + return -1; + } + pv_init_sbranch();
return 0; } diff --git a/modules/pv/pv_branch.c b/modules/pv/pv_branch.c index 6843b6c..e35330a 100644 --- a/modules/pv/pv_branch.c +++ b/modules/pv/pv_branch.c @@ -27,7 +27,12 @@ #include "pv_core.h" #include "pv_branch.h"
-static branch_t _pv_sbranch = {0}; +static branch_t _pv_sbranch; + +void pv_init_sbranch(void) +{ + memset(&_pv_sbranch, 0, sizeof(branch_t)); +}
int pv_get_branchx_helper(sip_msg_t *msg, pv_param_t *param, pv_value_t *res, int btype) @@ -46,6 +51,9 @@ int pv_get_branchx_helper(sip_msg_t *msg, pv_param_t *param, return pv_get_null(msg, param, res); } br = get_sip_branch(idx); + if(br==NULL) { + return pv_get_null(msg, param, res); + } }
/* branch(count) doesn't need a valid branch, everything else does */ @@ -685,10 +693,7 @@ int sbranch_append(sip_msg_t *msg) { str uri = {0}; str duri = {0}; - int lq = 0; str path = {0}; - unsigned int fl = 0; - struct socket_info* fsocket = NULL; str ruid = {0}; str location_ua = {0}; branch_t *br; diff --git a/modules/pv/pv_branch.h b/modules/pv/pv_branch.h index a5ee569..84b7972 100644 --- a/modules/pv/pv_branch.h +++ b/modules/pv/pv_branch.h @@ -46,6 +46,7 @@ int pv_parse_nh_name(pv_spec_p sp, str *in);
int sbranch_set_ruri(sip_msg_t *msg); int sbranch_append(sip_msg_t *msg); +void pv_init_sbranch(void); int sbranch_reset(void);
#endif