[sr-dev] git:master: rls: Fix memory leak with duplicate entries in lists

Hugh Waite hugh.waite at acision.com
Wed May 28 11:53:13 CEST 2014


Module: sip-router
Branch: master
Commit: a0c35bbfa84fd2212c05e5af1d2423a4a2e5e547
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a0c35bbfa84fd2212c05e5af1d2423a4a2e5e547

Author: Hugh Waite <hugh.waite at acision.com>
Committer: Hugh Waite <hugh.waite at acision.com>
Date:   Tue May 27 15:42:08 2014 +0100

rls: Fix memory leak with duplicate entries in lists

- When duplicate detection is requested, free the string and container
- When duplicate detection is not requested, insert the duplicate anyway

---

 modules/rls/list.h      |   12 ++++++++----
 modules/rls/subscribe.c |    2 ++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/modules/rls/list.h b/modules/rls/list.h
index f65c408..8c13b4d 100644
--- a/modules/rls/list.h
+++ b/modules/rls/list.h
@@ -41,9 +41,11 @@ static inline list_entry_t *list_insert(str *strng, list_entry_t *list, int *dup
 	if (cmp == 0)
 	{
 		if (duplicate != NULL)
+		{
 			*duplicate = 1;
-		pkg_free(p);
-		return list;
+			pkg_free(p);
+			return list;
+		}
 	}
 	if (cmp > 0)
 	{
@@ -59,9 +61,11 @@ static inline list_entry_t *list_insert(str *strng, list_entry_t *list, int *dup
 		if (cmp == 0)
 		{
 			if (duplicate != NULL)
+			{
 				*duplicate = 1;
-			pkg_free(p);
-			return list;
+				pkg_free(p);
+				return list;
+			}
 		}
 
 		p->next = q->next;
diff --git a/modules/rls/subscribe.c b/modules/rls/subscribe.c
index d15a601..7c45908 100644
--- a/modules/rls/subscribe.c
+++ b/modules/rls/subscribe.c
@@ -1037,6 +1037,8 @@ int send_resource_subs(char* uri, void* param)
 		LM_WARN("%.*s has %.*s multiple times in the same resource list\n",
 			s->watcher_uri->len, s->watcher_uri->s,
 			s->pres_uri->len, s->pres_uri->s);
+		pkg_free(tmp_str->s);
+		pkg_free(tmp_str);
 		return 1;
 	}
 




More information about the sr-dev mailing list