Browse Source

uac: safety check to be sure the reg hash table is initialized

- reported by Alex Villacís Lasso
Daniel-Constantin Mierla 11 years ago
parent
commit
b1900f66cc
1 changed files with 27 additions and 0 deletions
  1. 27 0
      modules/uac/uac_reg.c

+ 27 - 0
modules/uac/uac_reg.c

@@ -236,6 +236,12 @@ int reg_ht_add_byuuid(reg_uac_t *reg)
 	unsigned int slot;
 	unsigned int slot;
 	reg_item_t *ri = NULL;
 	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));
 	ri = (reg_item_t*)shm_malloc(sizeof(reg_item_t));
 	if(ri==NULL)
 	if(ri==NULL)
 	{
 	{
@@ -259,6 +265,12 @@ int reg_ht_add_byuser(reg_uac_t *reg)
 	unsigned int slot;
 	unsigned int slot;
 	reg_item_t *ri = NULL;
 	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));
 	ri = (reg_item_t*)shm_malloc(sizeof(reg_item_t));
 	if(ri==NULL)
 	if(ri==NULL)
 	{
 	{
@@ -346,6 +358,12 @@ reg_uac_t *reg_ht_get_byuuid(str *uuid)
 	unsigned int slot;
 	unsigned int slot;
 	reg_item_t *it = NULL;
 	reg_item_t *it = NULL;
 
 
+	if(_reg_htable==NULL)
+	{
+		LM_ERR("reg hash table not initialized\n");
+		return NULL;
+	}
+
 	hash = reg_compute_hash(uuid);
 	hash = reg_compute_hash(uuid);
 	slot = reg_get_entry(hash, _reg_htable->htsize);
 	slot = reg_get_entry(hash, _reg_htable->htsize);
 	it = _reg_htable->entries[slot].byuuid;
 	it = _reg_htable->entries[slot].byuuid;
@@ -370,6 +388,12 @@ reg_uac_t *reg_ht_get_byuser(str *user, str *domain)
 	unsigned int slot;
 	unsigned int slot;
 	reg_item_t *it = NULL;
 	reg_item_t *it = NULL;
 
 
+	if(_reg_htable==NULL)
+	{
+		LM_ERR("reg hash table not initialized\n");
+		return NULL;
+	}
+
 	hash = reg_compute_hash(user);
 	hash = reg_compute_hash(user);
 	slot = reg_get_entry(hash, _reg_htable->htsize);
 	slot = reg_get_entry(hash, _reg_htable->htsize);
 	it = _reg_htable->entries[slot].byuser;
 	it = _reg_htable->entries[slot].byuser;
@@ -740,6 +764,9 @@ void uac_reg_timer(unsigned int ticks)
 	reg_item_t *it = NULL;
 	reg_item_t *it = NULL;
 	time_t tn;
 	time_t tn;
 
 
+	if(_reg_htable==NULL)
+		return;
+
 	tn = time(NULL);
 	tn = time(NULL);
 	for(i=0; i<_reg_htable->htsize; i++)
 	for(i=0; i<_reg_htable->htsize; i++)
 	{
 	{