diff options
Diffstat (limited to 'libexslt')
-rw-r--r-- | libexslt/common.c | 7 | ||||
-rw-r--r-- | libexslt/math.c | 38 |
2 files changed, 44 insertions, 1 deletions
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); } |