[sr-dev] [SR-Users] memory leak fix on xcap_ auth.c

Daniel-Constantin Mierla miconda at gmail.com
Mon Jan 30 14:03:25 CET 2012


Hi Laura,

thanks for the patch. I wonder how an xcap related function landed in 
utils module, perhaps Juha felt more comfortable adding it there.

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.

Cheers,
Daniel

On 1/30/12 1:01 PM, laura testi wrote:
> 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
>
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla -- http://www.asipto.com
http://linkedin.com/in/miconda -- http://twitter.com/miconda

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-dev/attachments/20120130/88b8dd6f/attachment.htm>


More information about the sr-dev mailing list