After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 436324 - memory leak in exsltMathConstantFunction()
memory leak in exsltMathConstantFunction()
Status: RESOLVED FIXED
Product: libxslt
Classification: Platform
Component: general
1.1.20
Other Linux
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2007-05-06 11:47 UTC by Stefan Behnel
Modified: 2007-05-06 16:04 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Stefan Behnel 2007-05-06 11:47:20 UTC
For the following stylesheet, I get a memory loss report under valgrind:

-----------------------
<xsl:stylesheet version="1.0"
    xmlns:math="http://exslt.org/math"
    xmlns:str="http://exslt.org/strings"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    exclude-result-prefixes="math str xsl">
  <xsl:template match="text()">
    <xsl:value-of select="str:align(string(.), '---', 'center')" />
  </xsl:template>
  <xsl:template match="*">
    <xsl:copy>
      <xsl:attribute name="pi">
        <xsl:value-of select="math:constant('PI', count(*)+2)"/>
      </xsl:attribute>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
-----------------------

Note the use of the "PI" constant. This is the report:

-----------------------
==12768== 20 bytes in 6 blocks are definitely lost in loss record 7 of 78
==12768==    at 0x4021620: malloc (vg_replace_malloc.c:149)
==12768==    by 0x47D9E05: xmlStrndup (xmlstring.c:45)
==12768==    by 0x47D9F74: xmlStrsub (xmlstring.c:409)
==12768==    by 0x47379AD: exsltMathConstantFunction (math.c:443)
==12768==    by 0x47BE581: xmlXPathCompOpEval (xpath.c:13336)
==12768==    by 0x47BE00A: xmlXPathCompOpEval (xpath.c:13719)
==12768==    by 0x47BFDCF: xmlXPathRunEval (xpath.c:14287)
==12768==    by 0x47C4205: xmlXPathCompiledEvalInternal (xpath.c:14645)
==12768==    by 0x47C4411: xmlXPathCompiledEval (xpath.c:14709)
==12768==    by 0x4726A1A: xsltValueOf (transform.c:4396)
==12768==    by 0x4723AE6: xsltApplySequenceConstructor (transform.c:2580)
==12768==    by 0x4712AB7: xsltEvalTemplateString (templates.c:225)
-----------------------

I suspect the problem to be the math constant name (retrieved via xmlXPathPopString), which is not freed.
Comment 1 William M. Brack 2007-05-06 16:04:26 UTC
I found two separate places in math.c where leaks were occurring and fixed them.  Fixed code (libexslt/math.c) is in SVN.  It certainly cures your test case.  I'm closing the bug, but please re-open it (or open a new one) if you find any more.  Thanks for the report.