[xml] memory leak: attribute values are not freed when exception is thrown in the startElement callback



Hello,

We tried using libxml2 configured with the --with-fexceptions option and have identified a memory leak when our C++ startElement callback throws an exception.
The cause of the leak is as follows:
xmlParseStartTag frees all attribute values after calling the startElement callback, but since an exception is thrown in the callback, this cleanup code isn't executed.
xmlFreeParserCtxt only frees ctxt->atts: it doesn't try to free any leftover attribute values.

We tried to patch libxml2 to fix this issue but ran into errors when running make valgrind ("Memory tag error occurs"). So we decided to catch the exceptions in our callback instead which effectively prevents the memory leak from occurring.
We hope this issue will be fixed by someone with a deeper knowledge of libxml's design.

Best regards,
Bart



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