Bläddra i källkod

modules_k/rls: Fixed memory leak

- The pkg memory allocated for route-sets when sendin NOTIFY requests
  was never freed.
- Fixed by Paul Pankhurst @ Crocodile RCS
(cherry picked from commit 1b87bac8d5c56909ee4ae10f88dd8c6292b53e8a)
Peter Dunkley 13 år sedan
förälder
incheckning
203b10340d
1 ändrade filer med 14 tillägg och 11 borttagningar
  1. 14 11
      modules_k/rls/notify.c

+ 14 - 11
modules_k/rls/notify.c

@@ -714,11 +714,22 @@ error:
 	return NULL;
 
 }
+
 void rls_free_td(dlg_t* td)
 {
-		pkg_free(td->loc_uri.s);
-		pkg_free(td->rem_uri.s);
+	if(td)
+	{
+		if(td->loc_uri.s)
+			pkg_free(td->loc_uri.s);
+	
+		if(td->rem_uri.s)
+			pkg_free(td->rem_uri.s);
+
+		if(td->route_set)
+			pkg_free(td->route_set); 
+
 		pkg_free(td);
+	}	
 }
 
 int rls_send_notify(subs_t* subs, str* body, char* start_cid,
@@ -875,15 +886,7 @@ dlg_t* rls_notify_dlg(subs_t* subs)
 	return td;
 
 error:
-	if(td)
-	{
-		if(td->loc_uri.s)
-			pkg_free(td->loc_uri.s);
-	
-		if(td->rem_uri.s)
-			pkg_free(td->rem_uri.s);
-		pkg_free(td);
-	}	
+	if(td) rls_free_td(td);	
 
 	return NULL;