Re: [xml] Possible memory leak in xmlNodeDump()



Further to my last post, here's a patch which fixes the same problem in:

xmlDocContentDumpOutput()
xmlNodeDumpOutput()
xmlElemDump()

(as well as the original fix for xmlNodeDump() )

As I say, though, maybe I'm missing something or have made an incorrect
assumption about how these functions should be used, and this isn't really
a mem leak at all?

Thanks,

Steve

On Wed, 3 Mar 2004, Steve Little wrote:

Hi,
      I'm experiencing a memory leak when using xmlNodeDump() from
libxml 2.6.7. The following short snippet recreates the problem:

------8<-------8<---------

#include <libxml/tree.h>
#include <libxml/parser.h>

int main(void){
  xmlDocPtr doc = xmlParseFile("test.xml");
  xmlBufferPtr buff = xmlBufferCreate();
  xmlNodeDump(buff,doc,doc->children,0,0);
  xmlBufferFree(buff);
  xmlFreeDoc(doc);
}

----8<-------8<------

The problem seems to be caused because there's a call to xmlInitParser()
in xmlNodeDump(), but no corresponding call to xmlCleanupParser(). The
attached patch fixes the problem by adding a call to xmlCleanupParser().

Removing the call to xmlInitParser() would probably also fix it, but I'm
not 100% sure if it's needed or not. (It wasn't present in v2.5.3)

Or maybe I'm using xmlNodeDump() incorrectly? Is there some other cleanup
function I should be calling?

Thanks,

Steve

PS - Daniel, sorry for the previous send of this email, I accidentally
sent from a different, non-subscribed address

Attachment: tree.c.patch
Description: Text document



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