[libxslt] Fix a memory leak with xsl:number
- From: Daniel Veillard <veillard src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxslt] Fix a memory leak with xsl:number
- Date: Mon, 7 Mar 2011 04:23:04 +0000 (UTC)
commit f1dbababbb255f6182e3eb25f95a48b4df550a4a
Author: Daniel Veillard <veillard redhat com>
Date: Mon Mar 7 12:21:26 2011 +0800
Fix a memory leak with xsl:number
Pointed out by Ralf Junker <ralfjunker gmx de>, and added his
reproducer to the regression tests
libxslt/preproc.c | 4 ++++
tests/docs/bug-172.xml | 6 ++++++
tests/general/Makefile.am | 1 +
tests/general/bug-172.out | 6 ++++++
tests/general/bug-172.xsl | 22 ++++++++++++++++++++++
5 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/libxslt/preproc.c b/libxslt/preproc.c
index 4a4bfbf..11500c9 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 0000000..406f40d
--- /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 8f32fe7..72d649b 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 0000000..00dd75b
--- /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 0000000..07984f5
--- /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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]