Fix a memory leak with xsl:number
authorDaniel Veillard <veillard@redhat.com>
Mon, 7 Mar 2011 04:21:26 +0000 (12:21 +0800)
committerDaniel Veillard <veillard@redhat.com>
Mon, 7 Mar 2011 04:21:26 +0000 (12:21 +0800)
Pointed out by Ralf Junker <ralfjunker@gmx.de>, and added his
reproducer to the regression tests

libxslt/preproc.c
tests/docs/bug-172.xml [new file with mode: 0644]
tests/general/Makefile.am
tests/general/bug-172.out [new file with mode: 0644]
tests/general/bug-172.xsl [new file with mode: 0644]

index 4a4bfbf..11500c9 100644 (file)
@@ -498,6 +498,10 @@ xsltFreeStylePreComp(xsltStylePreCompPtr comp) {
        xsltFreeLocale(comp->locale);
     if (comp->comp != NULL)
        xmlXPathFreeCompExpr(comp->comp);
+    if (comp->numdata.countPat != NULL)
+        xsltFreeCompMatchList(comp->numdata.countPat);
+    if (comp->numdata.fromPat != NULL)
+        xsltFreeCompMatchList(comp->numdata.fromPat);
     if (comp->nsList != NULL)
        xmlFree(comp->nsList);
 #endif
diff --git a/tests/docs/bug-172.xml b/tests/docs/bug-172.xml
new file mode 100644 (file)
index 0000000..406f40d
--- /dev/null
@@ -0,0 +1,6 @@
+<params>
+<para bold="true">A first paragraph</para>
+<para>A second paragraph</para>
+<para>A third paragraph</para>
+<para>A fourth paragraph</para>
+</params>
\ No newline at end of file
index 8f32fe7..72d649b 100644 (file)
@@ -179,6 +179,7 @@ EXTRA_DIST = \
     bug-169.out bug-169.xsl bug-169.imp \
     bug-170.out bug-170.xsl \
     bug-171.out bug-171.xsl \
+    bug-172.out bug-172.xsl \
     character.out character.xsl \
     character2.out character2.xsl \
     itemschoose.out itemschoose.xsl \
diff --git a/tests/general/bug-172.out b/tests/general/bug-172.out
new file mode 100644 (file)
index 0000000..00dd75b
--- /dev/null
@@ -0,0 +1,6 @@
+<html><body>
+<p><b>1. A first paragraph</b></p>
+<p>2. A second paragraph</p>
+<p>3. A third paragraph</p>
+<p>4. A fourth paragraph</p>
+</body></html>
diff --git a/tests/general/bug-172.xsl b/tests/general/bug-172.xsl
new file mode 100644 (file)
index 0000000..07984f5
--- /dev/null
@@ -0,0 +1,22 @@
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match="para">
+   
+  <xsl:choose>
+    <xsl:when test="@bold='true'">
+      <p><b><xsl:number count="para" format="1. "/> <xsl:apply-templates/></b></p>
+    </xsl:when>
+    <xsl:otherwise>
+      <p><xsl:number count="para" format="1. "/> <xsl:apply-templates/></p>
+    </xsl:otherwise>
+  </xsl:choose>
+
+</xsl:template>
+
+<xsl:template match="/">
+  <html><body>
+    <xsl:apply-templates/>
+  </body></html>
+</xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file