diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2003-04-23 20:44:16 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2003-04-23 20:44:16 +0000 |
commit | 6c87e3dd3f46eadf7a7caabfc1c364cb4d1f4edb (patch) | |
tree | 49890172677b3698acba1be023fc33a7d3b182e4 | |
parent | ac5c2925a59714f99f28bf26135dad618e6ba9fd (diff) | |
download | libxslt-6c87e3dd3f46eadf7a7caabfc1c364cb4d1f4edb.tar.gz libxslt-6c87e3dd3f46eadf7a7caabfc1c364cb4d1f4edb.tar.bz2 libxslt-6c87e3dd3f46eadf7a7caabfc1c364cb4d1f4edb.zip |
applied last patch for #110023 from Mark Vakoc fixed a memory leak when
* libexslt/strings.c: applied last patch for #110023 from
Mark Vakoc
* libexslt/sets.c: fixed a memory leak when mixing one of the
EXSLT set functions and a Result Value Tree
* TODO: there are other bugs around in libexslt/sets.c in conjunction
with Result Value Tree
Daniel
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | TODO | 16 | ||||
-rw-r--r-- | libexslt/sets.c | 14 | ||||
-rw-r--r-- | libexslt/strings.c | 98 |
4 files changed, 77 insertions, 60 deletions
@@ -1,3 +1,12 @@ +Wed Apr 23 22:41:08 CEST 2003 Daniel Veillard <daniel@veillard.com> + + * libexslt/strings.c: applied last patch for #110023 from + Mark Vakoc + * libexslt/sets.c: fixed a memory leak when mixing one of the + EXSLT set functions and a Result Value Tree + * TODO: there are other bugs around in libexslt/sets.c in conjunction + with Result Value Tree + Wed Apr 23 17:00:16 CEST 2003 Daniel Veillard <daniel@veillard.com> * libxslt/extensions.c: patch from Vasily Tchekalkin fixing @@ -4,9 +4,9 @@ * * ******** -Design: - - seems that saving back XSLT stylesheet from a compiled form might - be a bit ugly ... Yes forget about it, it's just twaeked to the extreme +Lifetime of result Value Tree, make sure we keep pointers. Exslt +handling of node set values is especially nasty in this respect, +lots of potential mem leaks... Pattern tester: -> try to optimize for ID scan and tests. @@ -14,20 +14,10 @@ Pattern tester: Pattern scanner: -> add error checks on all returns -Error handling: - -> check the version stuff, design a separate module for error interfacing - and default handling, parsing vs. runtime, fatal / compat / warning, - and lack of optionnal features. - -> catch recursion end of 5.4 ... - Sorting: -> add lang and case-order -> add foreign sorting functions (interfaces ?). -Format Number: - -> cleanup % handling (May 21 2001) possibly following the cleaned - up wording of XSLT-2.0 - ******** * * * DONE * diff --git a/libexslt/sets.c b/libexslt/sets.c index 77e115e9..4f397621 100644 --- a/libexslt/sets.c +++ b/libexslt/sets.c @@ -99,13 +99,22 @@ exsltSetsIntersectionFunction (xmlXPathParserContextPtr ctxt, int nargs) { */ static void exsltSetsDistinctFunction (xmlXPathParserContextPtr ctxt, int nargs) { + xmlXPathObjectPtr obj; xmlNodeSetPtr ns, ret; + int boolval; + void *user; if (nargs != 1) { xmlXPathSetArityError(ctxt); return; } + if (ctxt->value != NULL) { + boolval = ctxt->value->boolval; + user = ctxt->value->user; + ctxt->value->boolval = 0; + ctxt->value->user = NULL; + } ns = xmlXPathPopNodeSet(ctxt); if (xmlXPathCheckError(ctxt)) return; @@ -116,7 +125,10 @@ exsltSetsDistinctFunction (xmlXPathParserContextPtr ctxt, int nargs) { if (ret != ns) xmlXPathFreeNodeSet(ns); - xmlXPathReturnNodeSet(ctxt, ret); + obj = xmlXPathWrapNodeSet(ns); + obj->user = user; + obj->boolval = boolval; + valuePush((ctxt), obj); } /** diff --git a/libexslt/strings.c b/libexslt/strings.c index d86bf6c1..6d7d02b0 100644 --- a/libexslt/strings.c +++ b/libexslt/strings.c @@ -30,7 +30,8 @@ * containing one token from the string. */ static void -exsltStrTokenizeFunction (xmlXPathParserContextPtr ctxt, int nargs) { +exsltStrTokenizeFunction(xmlXPathParserContextPtr ctxt, int nargs) +{ xmlChar *str, *delimiters, *cur; const xmlChar *token, *delimiter; xmlNodePtr node; @@ -39,64 +40,69 @@ exsltStrTokenizeFunction (xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathObjectPtr ret; if ((nargs < 1) || (nargs > 2)) { - xmlXPathSetArityError (ctxt); - return; + xmlXPathSetArityError(ctxt); + return; } if (nargs == 2) { - delimiters = xmlXPathPopString (ctxt); - if (xmlXPathCheckError(ctxt)) - return; + delimiters = xmlXPathPopString(ctxt); + if (xmlXPathCheckError(ctxt)) + return; } else { - delimiters = xmlStrdup((const xmlChar *) "\t\r\n "); + delimiters = xmlStrdup((const xmlChar *) "\t\r\n "); } if (delimiters == NULL) - return; + return; - str = xmlXPathPopString (ctxt); + str = xmlXPathPopString(ctxt); if (xmlXPathCheckError(ctxt) || (str == NULL)) { - xmlFree (delimiters); - return; + xmlFree(delimiters); + return; } - /* Return a result tree fragment */ - - container = xmlNewDoc(NULL); - if (container != NULL) { - container->name = (char *) xmlStrdup(BAD_CAST " fake node libxslt"); - container->doc = container; - ret = xmlXPathNewValueTree((xmlNodePtr) container); - if (ret != NULL) { - /* Tag the subtree for removal once consumed */ - ret->boolval = 1; - for (cur = str, token = str; *cur != 0; cur++) { - for (delimiter = delimiters; *delimiter != 0; delimiter++) { - if (*cur == *delimiter) { - if (cur == token) { - /* discard empty tokens */ - break; - } - *cur = 0; - node = xmlNewChild ( (xmlNodePtr) container, NULL, - (const xmlChar *) "token", token); - *cur = *delimiter; - token = cur + 1; - break; - } - } - } - node = xmlNewChild ((xmlNodePtr) container, NULL, (const xmlChar *) "token", token); - } - } + /* Return a result tree fragment */ + + container = xmlNewDoc(NULL); + if (container != NULL) { + container->name = + (char *) xmlStrdup(BAD_CAST " fake node libxslt"); + container->doc = container; + ret = xmlXPathNewValueTree((xmlNodePtr) container); + if (ret != NULL) { + /* Tag the subtree for removal once consumed */ + ret->boolval = 1; + ret->type = XPATH_NODESET; + for (cur = str, token = str; *cur != 0; cur++) { + for (delimiter = delimiters; *delimiter != 0; delimiter++) { + if (*cur == *delimiter) { + if (cur == token) { + /* discard empty tokens */ + break; + } + *cur = 0; + node = xmlNewChild((xmlNodePtr) container, NULL, + (const xmlChar *) "token", + token); + *cur = *delimiter; + token = cur + 1; + break; + } + } + } + node = + xmlNewChild((xmlNodePtr) container, NULL, + (const xmlChar *) "token", token); + } + } if (str != NULL) - xmlFree(str); + xmlFree(str); if (delimiters != NULL) - xmlFree(delimiters); - if (ret != NULL) - valuePush (ctxt, ret); - else - valuePush(ctxt,xmlXPathNewNodeSet(NULL)); + xmlFree(delimiters); + if (ret != NULL) + valuePush(ctxt, ret); + else + valuePush(ctxt, xmlXPathNewNodeSet(NULL)); } /** |