[gdome] Memory leak occurs when some node is appended to the entity reference node



 

Hi

According to DOM specification (2.0) an entity reference node can have following nodes as its child “Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference.”

And current Gdome implementation also allows us to append a child to the entity reference node.

Consider the following scenario-        

I am creating a document from scratch I create an entity reference node and add a text node as its child and finally append that entity reference node to the root element.  Now when I will save the tree to a File it will simply shows an entity reference on the doc. Hence appending the child has no effect. After the entire Tree is freed there is a memory leak as the text node appended to the entity is not freed. It’s because Gdome uses the Libxml function XmlFreeDoc () to free the document tree. Now inside xmlFreeDoc () xmlFreeNodeList () is called to free the children list of doc. In side this function the node type is checked before freeing the child list. If it is of entity reference node then its children are not freed which causes the memory leak in this scenario.

     As appending a child node to ER is of no use can we just make ER node as read-only so that it can’t be modified any way.

Thanks & Regards

     Rabi



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