Browse Source

modules/presence: prevent segfault on deref. of empty hashtable entry list

jaybeepee 9 years ago
parent
commit
83cf034c20
1 changed files with 2 additions and 2 deletions
  1. 2 2
      modules/presence/hash.c

+ 2 - 2
modules/presence/hash.c

@@ -112,7 +112,7 @@ subs_t* search_shtable(shtable_t htable,str callid,str to_tag,
 {
 {
 	subs_t* s;
 	subs_t* s;
 
 
-	s= htable[hash_code].entries->next;
+	s= htable[hash_code].entries?htable[hash_code].entries->next:NULL;
 
 
 	while(s)
 	while(s)
 	{
 	{
@@ -292,7 +292,7 @@ int delete_shtable(shtable_t htable,unsigned int hash_code,subs_t* subs)
 	lock_get(&htable[hash_code].lock);
 	lock_get(&htable[hash_code].lock);
 	
 	
 	ps= htable[hash_code].entries;
 	ps= htable[hash_code].entries;
-	s= ps->next;
+	s= ps?ps->next:NULL;
 		
 		
 	while(s)
 	while(s)
 	{
 	{