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

Author: Hugh Waite <[email protected]>
Committer: Hugh Waite <[email protected]>
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      |   10 ++++++++--
 modules/rls/subscribe.c |    2 ++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/modules/rls/list.h b/modules/rls/list.h
index c9904aa..8c13b4d 100644
--- a/modules/rls/list.h
+++ b/modules/rls/list.h
@@ -41,8 +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;
-               return list;
+                       pkg_free(p);
+                       return list;
+               }
        }
        if (cmp > 0)
        {
@@ -58,8 +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;
-                       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;
        }
 


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to