diff --git a/src/modules/drouting/drouting.c b/src/modules/drouting/drouting.c index e18ce7f76d1..d642716a3dc 100644 --- a/src/modules/drouting/drouting.c +++ b/src/modules/drouting/drouting.c @@ -979,6 +979,11 @@ static int fixup_do_routing(void** param, int param_no) if (param_no==1) { + if ( s==NULL || s[0]==0 ) { + LM_CRIT("empty group id definition"); + return E_CFG; + } + drg = (dr_group_t*)pkg_malloc(sizeof(dr_group_t)); if(drg==NULL) { @@ -987,33 +992,31 @@ static int fixup_do_routing(void** param, int param_no) } memset(drg, 0, sizeof(dr_group_t)); - if ( s==NULL || s[0]==0 ) { - LM_CRIT("empty group id definition"); - return E_CFG; - } - if (s[0]=='$') { /* param is a PV (AVP only supported) */ r.s = s; r.len = strlen(s); if (pv_parse_spec( &r, &avp_spec)==0 - || avp_spec.type!=PVT_AVP) { + || avp_spec.type!=PVT_AVP) { LM_ERR("malformed or non AVP %s AVP definition\n", s); + pkg_free(drg); return E_CFG; } if( pv_get_avp_name(0, &(avp_spec.pvp), &(drg->u.avp_id.name), - &(drg->u.avp_id.type) )!=0) { + &(drg->u.avp_id.type) )!=0) { LM_ERR("[%s]- invalid AVP definition\n", s); + pkg_free(drg); return E_CFG; } drg->type = 1; - /* do not free the param as the AVP spec may point inside - this string*/ + /* do not free the param as the AVP spec may point inside + * this string*/ } else { while(s && *s) { if(*s<'0' || *s>'9') { - LM_ERR( "bad number\n"); + LM_ERR("bad number\n"); + pkg_free(drg); return E_UNSPEC; } drg->u.grp_id = (drg->u.grp_id)*10+(*s-'0'); diff --git a/src/modules/drouting/prefix_tree.c b/src/modules/drouting/prefix_tree.c index 7eddab600df..cfb2cb15d7d 100644 --- a/src/modules/drouting/prefix_tree.c +++ b/src/modules/drouting/prefix_tree.c @@ -78,7 +78,8 @@ internal_check_rt( rt_info_wrp_t* rtlw=NULL; if((NULL==ptn) || (NULL==ptn->rg)) - goto err_exit; + return NULL; + rg_pos = ptn->rg_pos; rg=ptn->rg; for(i=0;(irtl->time_rec)) - goto ok_exit; + return rtlw->rtl; rtlw=rtlw->next; } } -err_exit: - return NULL; -ok_exit: - return rtlw?rtlw->rtl:0; + return NULL; } @@ -129,8 +127,6 @@ get_prefix( /* go the tree down to the last digit in the * prefix string or down to a leaf */ while(tmp< (prefix->s+prefix->len)) { - if(NULL == tmp) - goto err_exit; idx = get_node_index(*tmp); if (idx == -1){ /* unknown character in the prefix string */ @@ -147,11 +143,8 @@ get_prefix( ptree = ptree->ptnode[idx].next; tmp++; } - /* go in the tree up to the root trying to match the - * prefix */ + /* go in the tree up to the root trying to match the prefix */ while(ptree !=NULL ) { - if(NULL == tmp) - goto err_exit; /* is it a real node or an intermediate one */ idx = get_node_index(*tmp); if(idx!=-1 && NULL != ptree->ptnode[idx].rg) {