Module: sip-router Branch: 4.1 Commit: 35d83b91a8654a2218bf1ba900d7486fad189851 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=35d83b91...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Wed Apr 9 18:49:32 2014 +0200
uac: safety check to be sure the reg hash table is initialized
- reported by Alex VillacĂs Lasso
(cherry picked from commit b1900f66cc4acd254f1e6750538f31a3653fcd7f)
---
modules/uac/uac_reg.c | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/modules/uac/uac_reg.c b/modules/uac/uac_reg.c index 537ba82..8ab204f 100644 --- a/modules/uac/uac_reg.c +++ b/modules/uac/uac_reg.c @@ -236,6 +236,12 @@ int reg_ht_add_byuuid(reg_uac_t *reg) unsigned int slot; reg_item_t *ri = NULL;
+ if(_reg_htable==NULL) + { + LM_ERR("reg hash table not initialized\n"); + return -1; + } + ri = (reg_item_t*)shm_malloc(sizeof(reg_item_t)); if(ri==NULL) { @@ -259,6 +265,12 @@ int reg_ht_add_byuser(reg_uac_t *reg) unsigned int slot; reg_item_t *ri = NULL;
+ if(_reg_htable==NULL) + { + LM_ERR("reg hash table not initialized\n"); + return -1; + } + ri = (reg_item_t*)shm_malloc(sizeof(reg_item_t)); if(ri==NULL) { @@ -346,6 +358,12 @@ reg_uac_t *reg_ht_get_byuuid(str *uuid) unsigned int slot; reg_item_t *it = NULL;
+ if(_reg_htable==NULL) + { + LM_ERR("reg hash table not initialized\n"); + return NULL; + } + hash = reg_compute_hash(uuid); slot = reg_get_entry(hash, _reg_htable->htsize); it = _reg_htable->entries[slot].byuuid; @@ -370,6 +388,12 @@ reg_uac_t *reg_ht_get_byuser(str *user, str *domain) unsigned int slot; reg_item_t *it = NULL;
+ if(_reg_htable==NULL) + { + LM_ERR("reg hash table not initialized\n"); + return NULL; + } + hash = reg_compute_hash(user); slot = reg_get_entry(hash, _reg_htable->htsize); it = _reg_htable->entries[slot].byuser; @@ -740,6 +764,9 @@ void uac_reg_timer(unsigned int ticks) reg_item_t *it = NULL; time_t tn;
+ if(_reg_htable==NULL) + return; + tn = time(NULL); for(i=0; i<_reg_htable->htsize; i++) {