Переглянути джерело

Merge pull request #717 from athonet-open/fix_shutdown_presence

presence: fix potential double free in shutdown routine
Daniel-Constantin Mierla 9 роки тому
батько
коміт
3f92119fe1
1 змінених файлів з 7 додано та 2 видалено
  1. 7 2
      modules/presence/hash.c

+ 7 - 2
modules/presence/hash.c

@@ -318,9 +318,14 @@ int delete_shtable(shtable_t htable,unsigned int hash_code,subs_t* subs)
 		{
 		{
 			found= s->local_cseq +1;
 			found= s->local_cseq +1;
 			ps->next= s->next;
 			ps->next= s->next;
-			if(s->contact.s!=NULL)
+			if(s->contact.s!=NULL) {
 				shm_free(s->contact.s);
 				shm_free(s->contact.s);
-			shm_free(s);
+				s->contact.s = NULL;
+			}
+			if (s) {
+				shm_free(s);
+				s = NULL;
+			}
 			break;
 			break;
 		}
 		}
 		ps= s;
 		ps= s;