<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/4.2.2">
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#ffffff">
Hi Daniel,<BR>
<BR>
I remember looking at this file in the past.&nbsp; It seemed, to me at the time, to do a lot of the same stuff as the file with the same name in presence_xml but always with direct access to the xcap_server database.<BR>
<BR>
My thought at the time was that it could be used to run things like pres_auth_status() (xcap_auth_status() in utils) for blocking of IMs and calls based on the contents of XML documents without having to run the full set of presence modules.<BR>
<BR>
It looks like that fix is pretty similar to one I checked in for presence_xml/xcap_auth.c last week.<BR>
<BR>
Peter<BR>
<BR>
On Mon, 2012-01-30 at 14:03 +0100, Daniel-Constantin Mierla wrote:<BR>
<BLOCKQUOTE TYPE=CITE>
    Hi Laura,<BR>
    <BR>
    thanks for the patch. I wonder how an xcap related function landed in utils module, perhaps Juha felt more comfortable adding it there.<BR>
    <BR>
    At first sight, patch looks ok. I cc-ed Juha in case he wants to have a look and integrate it. If not, I will commit before 3.2.2.<BR>
    <BR>
    Cheers,<BR>
    Daniel<BR>
    <BR>
    On 1/30/12 1:01 PM, laura testi wrote: 
    <BLOCKQUOTE TYPE=CITE>
<PRE>
Hi Daniel,
I'm sending you some memory leak fix we have found and fixed on
modules/utils/xcap_ auth.c.

The fixed memory leak is in pres_watcher_allowed (), and it is about
the &quot;xmlFreeDoc&quot; that it's never called for the &quot;xcap_tree&quot; variable.

We downloaded the source file from master branch and then we fixed it.
You can find here the diff from original and new code and in attach
both the original and the new files.


diff -u a/modules/utils/xcap_auth.c b/modules/utils/xcap_auth.c
--- a/modules/utils/xcap_auth.c
+++ b/modules/utils/xcap_auth.c
@@ -280,13 +280,15 @@
     }

     node= get_rule_node(subs, xcap_tree);
-    if (node== NULL)
+    if (node== NULL){
+  xmlFreeDoc(xcap_tree);
        return 0;
-
+               }
     /* process actions */
     actions_node = xmlNodeGetChildByName(node, &quot;actions&quot;);
     if (actions_node == NULL) {
        LM_DBG(&quot;actions_node NULL\n&quot;);
+       xmlFreeDoc(xcap_tree);
        return 0;
     }
     LM_DBG(&quot;actions_node-&gt;name= %s\n&quot;, actions_node-&gt;name);
@@ -294,6 +296,7 @@
     sub_handling_node = xmlNodeGetChildByName(actions_node, &quot;sub-handling&quot;);
     if (sub_handling_node== NULL) {
        LM_DBG(&quot;sub_handling_node NULL\n&quot;);
+       xmlFreeDoc(xcap_tree);
        return 0;
     }
     sub_handling = (char*)xmlNodeGetContent(sub_handling_node);
@@ -302,6 +305,7 @@

     if (sub_handling == NULL) {
        LM_ERR(&quot;Couldn't get sub-handling content\n&quot;);
+       xmlFreeDoc(xcap_tree);
        return -1;
     }
     if (strncmp((char*)sub_handling, &quot;block&quot;, 5) == 0) {
@@ -325,10 +329,12 @@
            else {
                LM_ERR(&quot;unknown subscription handling action\n&quot;);
                xmlFree(sub_handling);
+               xmlFreeDoc(xcap_tree);
                return -1;
            }

     xmlFree(sub_handling);
+    xmlFreeDoc(xcap_tree);

     return 0;

Kind Regards,
laura
</PRE>
        <BR>
        <BR>
<PRE>
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<A HREF="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</A>
<A HREF="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</A>
</PRE>
    </BLOCKQUOTE>
    <BR>
<PRE>
-- 
Daniel-Constantin Mierla -- <A HREF="http://www.asipto.com">http://www.asipto.com</A>
<A HREF="http://linkedin.com/in/miconda">http://linkedin.com/in/miconda</A> -- <A HREF="http://twitter.com/miconda">http://twitter.com/miconda</A>
_______________________________________________
sr-dev mailing list
<A HREF="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</A>
<A HREF="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</A>
</PRE>
</BLOCKQUOTE>
<BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
<PRE>
-- 
Peter Dunkley
Technical Director
Crocodile RCS Ltd
</PRE>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>