diff options
author | William M. Brack <wbrack@src.gnome.org> | 2007-05-06 15:43:22 +0000 |
---|---|---|
committer | William M. Brack <wbrack@src.gnome.org> | 2007-05-06 15:43:22 +0000 |
commit | 9df6677d522ddc4543cb8b97f3c7aace9b5e7c06 (patch) | |
tree | 5752d4967a1ac1adf712ea999836cbe83eba391d /libexslt | |
parent | 085d8f89afd89397bbd0a4184c7a4ddb73e624e9 (diff) | |
download | libxslt-9df6677d522ddc4543cb8b97f3c7aace9b5e7c06.tar.gz libxslt-9df6677d522ddc4543cb8b97f3c7aace9b5e7c06.tar.bz2 libxslt-9df6677d522ddc4543cb8b97f3c7aace9b5e7c06.zip |
fixed two memory leaks, one in exsltMathConstant and one in
* libexslt/math.c: fixed two memory leaks, one in exsltMathConstant
and one in exsltMathConstantFunction (bug #436324)
svn path=/trunk/; revision=1427
Diffstat (limited to 'libexslt')
-rw-r--r-- | libexslt/math.c | 38 |
1 files changed, 9 insertions, 29 deletions
diff --git a/libexslt/math.c b/libexslt/math.c index 50a4e6a9..5c5720dd 100644 --- a/libexslt/math.c +++ b/libexslt/math.c @@ -357,6 +357,7 @@ exsltMathLowestFunction (xmlXPathParserContextPtr ctxt, int nargs) { static double exsltMathConstant (xmlChar *name, double precision) { xmlChar *str; + double ret; if ((name == NULL) || (xmlXPathIsNaN(precision)) || (precision < 1.0)) { return xmlXPathNAN; @@ -369,10 +370,6 @@ exsltMathConstant (xmlChar *name, double precision) { len = (int)precision; str = xmlStrsub(EXSLT_PI, 0, len); - if (str == NULL) - return xmlXPathNAN; - - return xmlXPathCastStringToNumber(str); } else if (xmlStrEqual(name, BAD_CAST "E")) { int len = xmlStrlen(EXSLT_E); @@ -381,10 +378,6 @@ exsltMathConstant (xmlChar *name, double precision) { len = (int)precision; str = xmlStrsub(EXSLT_E, 0, len); - if (str == NULL) - return xmlXPathNAN; - - return xmlXPathCastStringToNumber(str); } else if (xmlStrEqual(name, BAD_CAST "SQRRT2")) { int len = xmlStrlen(EXSLT_SQRRT2); @@ -393,10 +386,6 @@ exsltMathConstant (xmlChar *name, double precision) { len = (int)precision; str = xmlStrsub(EXSLT_SQRRT2, 0, len); - if (str == NULL) - return xmlXPathNAN; - - return xmlXPathCastStringToNumber(str); } else if (xmlStrEqual(name, BAD_CAST "LN2")) { int len = xmlStrlen(EXSLT_LN2); @@ -405,10 +394,6 @@ exsltMathConstant (xmlChar *name, double precision) { len = (int)precision; str = xmlStrsub(EXSLT_LN2, 0, len); - if (str == NULL) - return xmlXPathNAN; - - return xmlXPathCastStringToNumber(str); } else if (xmlStrEqual(name, BAD_CAST "LN10")) { int len = xmlStrlen(EXSLT_LN10); @@ -417,10 +402,6 @@ exsltMathConstant (xmlChar *name, double precision) { len = (int)precision; str = xmlStrsub(EXSLT_LN10, 0, len); - if (str == NULL) - return xmlXPathNAN; - - return xmlXPathCastStringToNumber(str); } else if (xmlStrEqual(name, BAD_CAST "LOG2E")) { int len = xmlStrlen(EXSLT_LOG2E); @@ -429,10 +410,6 @@ exsltMathConstant (xmlChar *name, double precision) { len = (int)precision; str = xmlStrsub(EXSLT_LOG2E, 0, len); - if (str == NULL) - return xmlXPathNAN; - - return xmlXPathCastStringToNumber(str); } else if (xmlStrEqual(name, BAD_CAST "SQRT1_2")) { int len = xmlStrlen(EXSLT_SQRT1_2); @@ -441,14 +418,15 @@ exsltMathConstant (xmlChar *name, double precision) { len = (int)precision; str = xmlStrsub(EXSLT_SQRT1_2, 0, len); - if (str == NULL) - return xmlXPathNAN; - - return xmlXPathCastStringToNumber(str); } else { + str = NULL; + } + if (str == NULL) return xmlXPathNAN; - } + ret = xmlXPathCastStringToNumber(str); + xmlFree(str); + return ret; } /** @@ -476,6 +454,8 @@ exsltMathConstantFunction (xmlXPathParserContextPtr ctxt, int nargs) { return; ret = exsltMathConstant(name, ret); + if (name != NULL) + xmlFree(name); xmlXPathReturnNumber(ctxt, ret); } |