[xml] xpath/xslt memory leak

I think I've found a nice memory leak. I'm using xslt to reproduce it, but I think that bug is in xpath module, so I send it here.

The program is just transforming simple document in loop:

#include <libxml/parser.h>
#include <libxslt/xslt.h>
#include <libxslt/transform.h>

int main(int argc, char **argv) {
        xsltStylesheetPtr cur;
        xmlDocPtr doc, res;

        xmlLoadExtDtdDefaultValue = 1;

        cur = xsltParseStylesheetFile("b.xsl");
        while (1) {
                doc = xmlParseFile("b.xml");
                res = xsltApplyStylesheet(cur, doc, NULL);

Document (b.xml) is like that:
<?xml version="1.0"?>
<params xmlns="http://www.praterm.com.pl/SZARP/ipk";>
        <raport title="A"/>

and stylesheet:

<?xml version="1.0"?>

                              <xsl:stylesheet version="1.0"

                            <!-- <xsl:param name="title"/> -->
  <xsl:template match="ipk:params">
    <xsl:element name="report">
      <xsl:for-each select="//ipk:param[ipk:raport[ title=$title]]">
        <xsl:element name="param">

The stylesheet is somewhat incorrect - declaration of parameter 'title' is missing. This simple program keeps allocating more and more memory (can be viewed with top/htop). When I uncomment the parameter declaration, everything works OK.
And, btw - the output from valgrind differs when I use '--leak-resolution=high'.
Checked with 2.6.18, but there's nothing about it in changelog, so I suppose its still there.
Files in attachment for convenience.

Paweł Pałucha

Attachment: xpath-memleak.tgz
Description: GNU Unix tar archive

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