summaryrefslogtreecommitdiff
path: root/xpath.c
diff options
context:
space:
mode:
authorMike Hommey <mh@glandium.org>2004-09-10 05:26:00 +0000
committerMike Hommey <mh@glandium.org>2004-09-10 05:26:00 +0000
commit09deb06614c3408ec0816a3c88920138bae2083c (patch)
treea1b841a7dc28eecb98ca361c9371ecd1449a1908 /xpath.c
parentc14c53a3645d81281058d4bb4cff24fa8d6faf33 (diff)
downloadlibxml2-09deb06614c3408ec0816a3c88920138bae2083c.tar.gz
Load /tmp/tmp.BmUFjT/libxml2-2.6.13 intoupstream/2.6.13
packages/libxml2/branches/upstream/current.
Diffstat (limited to 'xpath.c')
-rw-r--r--xpath.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/xpath.c b/xpath.c
index 9bbfdce..3d21e72 100644
--- a/xpath.c
+++ b/xpath.c
@@ -1235,9 +1235,11 @@ xmlXPathPopNodeSet (xmlXPathParserContextPtr ctxt) {
}
obj = valuePop(ctxt);
ret = obj->nodesetval;
+#if 0
/* to fix memory leak of not clearing obj->user */
if (obj->boolval && obj->user != NULL)
xmlFreeNodeList((xmlNodePtr) obj->user);
+#endif
xmlXPathFreeNodeSetList(obj);
return(ret);
}
@@ -2809,7 +2811,7 @@ xmlXPathRegisterFuncLookup (xmlXPathContextPtr ctxt,
void *funcCtxt) {
if (ctxt == NULL)
return;
- ctxt->funcLookupFunc = (void *) f;
+ ctxt->funcLookupFunc = f;
ctxt->funcLookupData = funcCtxt;
}
@@ -2832,7 +2834,7 @@ xmlXPathFunctionLookup(xmlXPathContextPtr ctxt, const xmlChar *name) {
xmlXPathFunction ret;
xmlXPathFuncLookupFunc f;
- f = (xmlXPathFuncLookupFunc) ctxt->funcLookupFunc;
+ f = ctxt->funcLookupFunc;
ret = f(ctxt->funcLookupData, name, NULL);
if (ret != NULL)
return(ret);
@@ -2863,7 +2865,7 @@ xmlXPathFunctionLookupNS(xmlXPathContextPtr ctxt, const xmlChar *name,
xmlXPathFunction ret;
xmlXPathFuncLookupFunc f;
- f = (xmlXPathFuncLookupFunc) ctxt->funcLookupFunc;
+ f = ctxt->funcLookupFunc;
ret = f(ctxt->funcLookupData, name, ns_uri);
if (ret != NULL)
return(ret);
@@ -2959,7 +2961,7 @@ xmlXPathRegisterVariableLookup(xmlXPathContextPtr ctxt,
xmlXPathVariableLookupFunc f, void *data) {
if (ctxt == NULL)
return;
- ctxt->varLookupFunc = (void *) f;
+ ctxt->varLookupFunc = f;
ctxt->varLookupData = data;
}
@@ -3310,6 +3312,12 @@ xmlXPathObjectCopy(xmlXPathObjectPtr val) {
ret->stringval = xmlStrdup(val->stringval);
break;
case XPATH_XSLT_TREE:
+#if 0
+/*
+ Removed 11 July 2004 - the current handling of xslt tmpRVT nodes means that
+ this previous handling is no longer correct, and can cause some serious
+ problems (ref. bug 145547)
+*/
if ((val->nodesetval != NULL) &&
(val->nodesetval->nodeTab != NULL)) {
xmlNodePtr cur, tmp;
@@ -3329,11 +3337,13 @@ xmlXPathObjectCopy(xmlXPathObjectPtr val) {
cur = cur->next;
}
}
+
ret->nodesetval = xmlXPathNodeSetCreate((xmlNodePtr) top);
} else
ret->nodesetval = xmlXPathNodeSetCreate(NULL);
/* Deallocate the copied tree value */
break;
+#endif
case XPATH_NODESET:
ret->nodesetval = xmlXPathNodeSetMerge(NULL, val->nodesetval);
/* Do not deallocate the copied tree value */
@@ -3370,10 +3380,13 @@ xmlXPathFreeObject(xmlXPathObjectPtr obj) {
if (obj == NULL) return;
if ((obj->type == XPATH_NODESET) || (obj->type == XPATH_XSLT_TREE)) {
if (obj->boolval) {
+#if 0
if (obj->user != NULL) {
xmlXPathFreeNodeSet(obj->nodesetval);
xmlFreeNodeList((xmlNodePtr) obj->user);
- } else if (obj->nodesetval != NULL)
+ } else
+#endif
+ if (obj->nodesetval != NULL)
xmlXPathFreeValueTree(obj->nodesetval);
} else {
if (obj->nodesetval != NULL)
@@ -10403,6 +10416,7 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
xmlNodeSetPtr newset = NULL;
xmlNodeSetPtr oldset;
xmlNodePtr oldnode;
+ xmlDocPtr oldDoc;
int i;
/*
@@ -10587,6 +10601,7 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
oldset = obj->nodesetval;
oldnode = ctxt->context->node;
+ oldDoc = ctxt->context->doc;
ctxt->context->node = NULL;
if ((oldset == NULL) || (oldset->nodeNr == 0)) {
@@ -10608,6 +10623,8 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
} else {
/*
* Initialize the new set.
+ * Also set the xpath document in case things like
+ * key() evaluation are attempted on the predicate
*/
newset = xmlXPathNodeSetCreate(NULL);
@@ -10617,6 +10634,9 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
* a single item in the nodeset.
*/
ctxt->context->node = oldset->nodeTab[i];
+ if ((oldset->nodeTab[i]->type != XML_NAMESPACE_DECL) &&
+ (oldset->nodeTab[i]->doc != NULL))
+ ctxt->context->doc = oldset->nodeTab[i]->doc;
tmp = xmlXPathNewNodeSet(ctxt->context->node);
valuePush(ctxt, tmp);
ctxt->context->contextSize = oldset->nodeNr;
@@ -10657,6 +10677,8 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
ctxt->context->node = NULL;
ctxt->context->contextSize = -1;
ctxt->context->proximityPosition = -1;
+ /* may want to move this past the '}' later */
+ ctxt->context->doc = oldDoc;
valuePush(ctxt, xmlXPathWrapNodeSet(newset));
}
ctxt->context->node = oldnode;