Module: sip-router
Branch: 3.2
Commit: 44eed062fa8d82ff0975b7d02e2360abd4e85364
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=44eed06…
Author: pd <peter.dunkley(a)crocodile-rcs.com>
Committer: pd <peter.dunkley(a)crocodile-rcs.com>
Date: Tue Jan 24 17:18:34 2012 +0000
modules_k/presence_xml: Fixed memory leak in pres_watcher_allowed()
- xmlFreeDoc() never called for xcap_tree
- Found and fixed by Paul Pankhurst @ Crocodile RCS
(cherry picked from commit fcd33bdfa3e5a08f22f4c77fbbf1db53d0afb4bd)
---
modules_k/presence_xml/xcap_auth.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/modules_k/presence_xml/xcap_auth.c b/modules_k/presence_xml/xcap_auth.c
index e9f2ad8..9838a06 100644
--- a/modules_k/presence_xml/xcap_auth.c
+++ b/modules_k/presence_xml/xcap_auth.c
@@ -83,13 +83,17 @@ int pres_watcher_allowed(subs_t* subs)
node= get_rule_node(subs, xcap_tree);
if(node== NULL)
+ {
+ xmlFreeDoc(xcap_tree);
return 0;
+ }
/* process actions */
actions_node = xmlNodeGetChildByName(node, "actions");
if(actions_node == NULL)
{
LM_DBG("actions_node NULL\n");
+ xmlFreeDoc(xcap_tree);
return 0;
}
LM_DBG("actions_node->name= %s\n",
@@ -99,6 +103,7 @@ int pres_watcher_allowed(subs_t* subs)
if(sub_handling_node== NULL)
{
LM_DBG("sub_handling_node NULL\n");
+ xmlFreeDoc(xcap_tree);
return 0;
}
sub_handling = (char*)xmlNodeGetContent(sub_handling_node);
@@ -110,6 +115,7 @@ int pres_watcher_allowed(subs_t* subs)
if(sub_handling== NULL)
{
LM_ERR("Couldn't get sub-handling content\n");
+ xmlFreeDoc(xcap_tree);
return -1;
}
if( strncmp((char*)sub_handling, "block",5 )==0)
@@ -130,9 +136,9 @@ int pres_watcher_allowed(subs_t* subs)
subs->reason.s= "polite-block";
subs->reason.len = 12;
}
- else
+ else
if( strncmp((char*)sub_handling , "allow",5 )==0)
- {
+ {
subs->status = ACTIVE_STATUS;
subs->reason.s = NULL;
}
@@ -140,11 +146,12 @@ int pres_watcher_allowed(subs_t* subs)
{
LM_ERR("unknown subscription handling action\n");
xmlFree(sub_handling);
+ xmlFreeDoc(xcap_tree);
return -1;
}
xmlFree(sub_handling);
-
+ xmlFreeDoc(xcap_tree);
return 0;
}