From: William M. Brack Date: Wed, 14 Jan 2004 06:34:43 +0000 (+0000) Subject: fixed problem, reported on the list by Markus Bayerlein, concerning math X-Git-Tag: v1.1.28~508 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=62742bd4fea91e9b6b6feeef3e53bb9811807903;p=platform%2Fupstream%2Flibxslt.git fixed problem, reported on the list by Markus Bayerlein, concerning math * libexslt/math.c, libexslt/common.c: fixed problem, reported on the list by Markus Bayerlein, concerning math functions on nodesets generated with exslt:node-set * tests/exslt/math/max.3.xsl, tests/exslt/math/max.3.xml, tests/exslt/math/max.3.out, tests/exslt/math/Makefile.am: added test case for above. --- diff --git a/ChangeLog b/ChangeLog index 9dd53d9..ca1b6e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Wed Jan 14 14:28:02 HKT 2004 William Brack + + * libexslt/math.c, libexslt/common.c: fixed problem, + reported on the list by Markus Bayerlein, concerning + math functions on nodesets generated with + exslt:node-set + * tests/exslt/math/max.3.xsl, tests/exslt/math/max.3.xml, + tests/exslt/math/max.3.out, tests/exslt/math/Makefile.am: + added test case for above. + Tue Jan 13 00:33:50 HKT 2004 William Brack * libxslt/transform.c: changed to assure comment which diff --git a/libexslt/common.c b/libexslt/common.c index 86538f0..ffed71b 100644 --- a/libexslt/common.c +++ b/libexslt/common.c @@ -40,7 +40,12 @@ exsltNodeSetFunction (xmlXPathParserContextPtr ctxt, int nargs) { strval = xmlXPathPopString (ctxt); retNode = xmlNewDocText (NULL, strval); ret = xmlXPathNewValueTree (retNode); - ret->type = XPATH_NODESET; + if (ret == NULL) { + xsltGenericError(xsltGenericErrorContext, + "exsltNodeSetFunction: ret == NULL\n"); + } else { + ret->type = XPATH_NODESET; + } if (strval != NULL) xmlFree (strval); diff --git a/libexslt/math.c b/libexslt/math.c index 2c0c884..50a4e6a 100644 --- a/libexslt/math.c +++ b/libexslt/math.c @@ -68,6 +68,7 @@ static void exsltMathMinFunction (xmlXPathParserContextPtr ctxt, int nargs) { xmlNodeSetPtr ns; double ret; + void *user = NULL; if (nargs != 1) { xsltGenericError(xsltGenericErrorContext, @@ -75,6 +76,12 @@ exsltMathMinFunction (xmlXPathParserContextPtr ctxt, int nargs) { ctxt->error = XPATH_INVALID_ARITY; return; } + /* We need to delay the freeing of value->user */ + if ((ctxt->value != NULL) && (ctxt->value->boolval != 0)) { + user = ctxt->value->user; + ctxt->value->boolval = 0; + ctxt->value->user = NULL; + } ns = xmlXPathPopNodeSet(ctxt); if (xmlXPathCheckError(ctxt)) return; @@ -82,6 +89,8 @@ exsltMathMinFunction (xmlXPathParserContextPtr ctxt, int nargs) { ret = exsltMathMin(ns); xmlXPathFreeNodeSet(ns); + if (user != NULL) + xmlFreeNodeList((xmlNodePtr)user); xmlXPathReturnNumber(ctxt, ret); } @@ -128,11 +137,19 @@ static void exsltMathMaxFunction (xmlXPathParserContextPtr ctxt, int nargs) { xmlNodeSetPtr ns; double ret; + void *user = NULL; if (nargs != 1) { xmlXPathSetArityError(ctxt); return; } + + /* We need to delay the freeing of value->user */ + if ((ctxt->value != NULL) && (ctxt->value->boolval != 0)) { + user = ctxt->value->user; + ctxt->value->boolval = 0; + ctxt->value->user = 0; + } ns = xmlXPathPopNodeSet(ctxt); if (xmlXPathCheckError(ctxt)) return; @@ -141,6 +158,8 @@ exsltMathMaxFunction (xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathFreeNodeSet(ns); + if (user != NULL) + xmlFreeNodeList((xmlNodePtr)user); xmlXPathReturnNumber(ctxt, ret); } @@ -198,12 +217,19 @@ exsltMathHighest (xmlNodeSetPtr ns) { static void exsltMathHighestFunction (xmlXPathParserContextPtr ctxt, int nargs) { xmlNodeSetPtr ns, ret; + void *user = NULL; if (nargs != 1) { xmlXPathSetArityError(ctxt); return; } + /* We need to delay the freeing of value->user */ + if ((ctxt->value != NULL) && ctxt->value->boolval != 0) { + user = ctxt->value->user; + ctxt->value->boolval = 0; + ctxt->value->user = NULL; + } ns = xmlXPathPopNodeSet(ctxt); if (xmlXPathCheckError(ctxt)) return; @@ -211,6 +237,8 @@ exsltMathHighestFunction (xmlXPathParserContextPtr ctxt, int nargs) { ret = exsltMathHighest(ns); xmlXPathFreeNodeSet(ns); + if (user != NULL) + xmlFreeNodeList((xmlNodePtr)user); xmlXPathReturnNodeSet(ctxt, ret); } @@ -269,12 +297,20 @@ exsltMathLowest (xmlNodeSetPtr ns) { static void exsltMathLowestFunction (xmlXPathParserContextPtr ctxt, int nargs) { xmlNodeSetPtr ns, ret; + void *user = NULL; + if (nargs != 1) { xmlXPathSetArityError(ctxt); return; } + /* We need to delay the freeing of value->user */ + if ((ctxt->value != NULL) && (ctxt->value->boolval != 0)) { + user = ctxt->value->user; + ctxt->value->boolval = 0; + ctxt->value->user = NULL; + } ns = xmlXPathPopNodeSet(ctxt); if (xmlXPathCheckError(ctxt)) return; @@ -282,6 +318,8 @@ exsltMathLowestFunction (xmlXPathParserContextPtr ctxt, int nargs) { ret = exsltMathLowest(ns); xmlXPathFreeNodeSet(ns); + if (user != NULL) + xmlFreeNodeList((xmlNodePtr)user); xmlXPathReturnNodeSet(ctxt, ret); } diff --git a/tests/exslt/math/Makefile.am b/tests/exslt/math/Makefile.am index d2cae4b..f3bae1f 100644 --- a/tests/exslt/math/Makefile.am +++ b/tests/exslt/math/Makefile.am @@ -11,6 +11,7 @@ EXTRA_DIST = \ lowest.2.out lowest.2.xml lowest.2.xsl \ max.1.out max.1.xml max.1.xsl \ max.2.out max.2.xml max.2.xsl \ + max.3.out max.3.xml max.3.xsl \ max.5.out max.5.xml max.5.xsl \ power.1.out power.1.xml power.1.xsl \ min.1.out min.1.xml min.1.xsl \