fixed problem, reported on the list by Markus Bayerlein, concerning math
authorWilliam M. Brack <wbrack@src.gnome.org>
Wed, 14 Jan 2004 06:34:43 +0000 (06:34 +0000)
committerWilliam M. Brack <wbrack@src.gnome.org>
Wed, 14 Jan 2004 06:34:43 +0000 (06:34 +0000)
* 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.

ChangeLog
libexslt/common.c
libexslt/math.c
tests/exslt/math/Makefile.am

index 9dd53d9..ca1b6e9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index 86538f0..ffed71b 100644 (file)
@@ -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);
index 2c0c884..50a4e6a 100644 (file)
@@ -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);
 }
index d2cae4b..f3bae1f 100644 (file)
@@ -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         \