[sr-dev] git:master:dc6962fb: presence: fix multiple double free on shutdown caught with memlog=1

Dragos Oancea dragos.oancea at athonet.com
Mon Aug 22 09:40:27 CEST 2016


Module: kamailio
Branch: master
Commit: dc6962fb7e02cf44a145e0bafa455873c73ebc2d
URL: https://github.com/kamailio/kamailio/commit/dc6962fb7e02cf44a145e0bafa455873c73ebc2d

Author: Dragos Oancea <dragos.oancea at athonet.com>
Committer: Dragos Oancea <dragos.oancea at athonet.com>
Date: 2016-08-19T17:00:00+02:00

presence: fix multiple double free on shutdown caught with memlog=1

---

Modified: modules/presence/hash.c

---

Diff:  https://github.com/kamailio/kamailio/commit/dc6962fb7e02cf44a145e0bafa455873c73ebc2d.diff
Patch: https://github.com/kamailio/kamailio/commit/dc6962fb7e02cf44a145e0bafa455873c73ebc2d.patch

---

diff --git a/modules/presence/hash.c b/modules/presence/hash.c
index 50657e0..bfce59d 100644
--- a/modules/presence/hash.c
+++ b/modules/presence/hash.c
@@ -101,6 +101,7 @@ void destroy_shtable(shtable_t htable, int hash_size)
 		lock_destroy(&htable[i].lock);
 		free_subs_list(htable[i].entries->next, SHM_MEM_TYPE, 1);
 		shm_free(htable[i].entries);
+		htable[i].entries = NULL;
 	}
 	shm_free(htable);
 	htable= NULL;
@@ -345,15 +346,21 @@ void free_subs_list(subs_t* s_array, int mem_type, int ic)
 		s_array= s_array->next;
 		if(mem_type & PKG_MEM_TYPE)
 		{
-			if(ic)
+			if(ic) {
 				pkg_free(s->contact.s);
+				s->contact.s = NULL;
+			}
 			pkg_free(s);
+			s = NULL;
 		}
 		else
 		{
-			if(ic)
+			if(ic) {
 				shm_free(s->contact.s);
+				s->contact.s = NULL;
+			}
 			shm_free(s);
+			s = NULL;
 		}
 	}
 	




More information about the sr-dev mailing list