summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@redhat.com>2011-03-07 12:21:26 +0800
committerDaniel Veillard <veillard@redhat.com>2011-03-07 12:21:26 +0800
commitf1dbababbb255f6182e3eb25f95a48b4df550a4a (patch)
tree282cb1a8f9acae1b0f4222af287c2b40dcc0ab31
parent4e9909066731067d8e256ca25d8d54944105bc5e (diff)
downloadlibxslt-f1dbababbb255f6182e3eb25f95a48b4df550a4a.tar.gz
libxslt-f1dbababbb255f6182e3eb25f95a48b4df550a4a.tar.bz2
libxslt-f1dbababbb255f6182e3eb25f95a48b4df550a4a.zip
Fix a memory leak with xsl:number
Pointed out by Ralf Junker <ralfjunker@gmx.de>, and added his reproducer to the regression tests
-rw-r--r--libxslt/preproc.c4
-rw-r--r--tests/docs/bug-172.xml6
-rw-r--r--tests/general/Makefile.am1
-rw-r--r--tests/general/bug-172.out6
-rw-r--r--tests/general/bug-172.xsl22
5 files changed, 39 insertions, 0 deletions
diff --git a/libxslt/preproc.c b/libxslt/preproc.c
index 4a4bfbfd..11500c94 100644
--- a/libxslt/preproc.c
+++ b/libxslt/preproc.c
@@ -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
index 00000000..406f40d1
--- /dev/null
+++ b/tests/docs/bug-172.xml
@@ -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
diff --git a/tests/general/Makefile.am b/tests/general/Makefile.am
index 8f32fe7f..72d649b5 100644
--- a/tests/general/Makefile.am
+++ b/tests/general/Makefile.am
@@ -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
index 00000000..00dd75b9
--- /dev/null
+++ b/tests/general/bug-172.out
@@ -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
index 00000000..07984f59
--- /dev/null
+++ b/tests/general/bug-172.xsl
@@ -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