diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | libexslt/common.c | 7 | ||||
-rw-r--r-- | libexslt/math.c | 38 | ||||
-rw-r--r-- | tests/exslt/math/Makefile.am | 1 |
4 files changed, 55 insertions, 1 deletions
@@ -1,3 +1,13 @@ +Wed Jan 14 14:28:02 HKT 2004 William Brack <wbrack@mmm.com.hk> + + * 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 <wbrack@mmm.com.hk> * libxslt/transform.c: changed to assure comment which diff --git a/libexslt/common.c b/libexslt/common.c index 86538f02..ffed71b6 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 2c0c8848..50a4e6a9 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 d2cae4b6..f3bae1f3 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 \ |