Skip to content
Browse files

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
  • Loading branch information...
1 parent ac5c292 commit 6c87e3dd3f46eadf7a7caabfc1c364cb4d1f4edb Daniel Veillard committed Apr 23, 2003
Showing with 77 additions and 60 deletions.
  1. +9 −0 ChangeLog
  2. +3 −13 TODO
  3. +13 −1 libexslt/sets.c
  4. +52 −46 libexslt/strings.c
View
9 ChangeLog
@@ -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
View
16 TODO
@@ -4,30 +4,20 @@
* *
********
-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.
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 *
View
14 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);
}
/**
View
98 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));
}
/**

0 comments on commit 6c87e3d

Please sign in to comment.
Something went wrong with that request. Please try again.