[gdome] Fix for the memory leak Xpath Module



Hi

For the memory leak problem in xpath module when the node returned by the gdome_xpath_xpresult_singleNodeValue() is a Namespace

Declaration node

Solution- In the gdome_xml_n_unref we have add one more check for the XML_NAMESPACE_DECL node like in mkref() and then call the

         gdome_xml_xpns_unref(). In side the gdome_xml_xpns_unref()when the refcnt becomes 0 we have to free the corresponding xmlNode

         object stored in the "n" field of the Gdome_xml_XPathNamespace object before freeing it.

The fix is given below

gdome-xml-node.c    Wed Jan 23 16:35:34 2008

gdome_xml_n_unref (GdomeNode *self, GdomeException *exc)

275a276,278

>   case XML_NAMESPACE_DECL:

>     gdome_xml_xpns_unref(self,exc);

>     return;

 gdome-xml-xpns.c    Wed Jan 23 16:29:34 2008

 in the function gdome_xml_xpns_unref (GdomeNode *self, GdomeException *exc)

 --- 111,121 ----

      if (priv->refcnt > 0)

          priv->refcnt--;

 

!     if (priv->refcnt == 0)

!     {

!     gdome_xmlFreeNode (priv->n);

      g_free (self);

!     }

  }

Thanks & Regards

        Rabi



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]