[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openser-devel
Subject:    [sr-dev] memory leak fix on xcap_ auth.c
From:       laura testi <lau.testi () gmail ! com>
Date:       2012-01-30 12:01:07
Message-ID: CAHFjjJNPEzfUsYfQes9ZqDE7NQ4u9CCSf1vngvihx9MEuA+r9A () mail ! gmail ! com
[Download RAW message or body]

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 "xmlFreeDoc" that it's never called for the "xcap_tree" 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, "actions");
     if (actions_node == NULL) {
        LM_DBG("actions_node NULL\n");
+       xmlFreeDoc(xcap_tree);
        return 0;
     }
     LM_DBG("actions_node->name= %s\n", actions_node->name);
@@ -294,6 +296,7 @@
     sub_handling_node = xmlNodeGetChildByName(actions_node, "sub-handling");
     if (sub_handling_node== NULL) {
        LM_DBG("sub_handling_node NULL\n");
+       xmlFreeDoc(xcap_tree);
        return 0;
     }
     sub_handling = (char*)xmlNodeGetContent(sub_handling_node);
@@ -302,6 +305,7 @@

     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) {
@@ -325,10 +329,12 @@
            else {
                LM_ERR("unknown subscription handling action\n");
                xmlFree(sub_handling);
+               xmlFreeDoc(xcap_tree);
                return -1;
            }

     xmlFree(sub_handling);
+    xmlFreeDoc(xcap_tree);

     return 0;

Kind Regards,
laura

["xcap_auth.c.new" (application/octet-stream)]
["xcap_auth.c.orig" (application/octet-stream)]

_______________________________________________
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic