Fixed memory leak reported by Dave Beckett Removed spurious comment
* parser.c, xmlmemory.c, include/libxml/xmlmemory.h: Fixed
memory leak reported by Dave Beckett
* xmlschemas.c: Removed spurious comment reported on the mailing
list
* xinclude.c, xpath.c, xpointer.c, libxml/include/xpointer.h:
Further work on Bug 129967 concerning xpointer range handling
and range-to function; much better, but still not complete
diff --git a/xpath.c b/xpath.c
index 0fa53b8..563e307 100644
--- a/xpath.c
+++ b/xpath.c
@@ -10307,11 +10307,12 @@
ctxt->context->doc = bakd;
ctxt->context->node = bak;
CHECK_ERROR0;
- if (op->ch2 != -1)
+ if (op->ch2 != -1) {
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
- ctxt->context->doc = bakd;
- ctxt->context->node = bak;
- CHECK_ERROR0;
+ ctxt->context->doc = bakd;
+ ctxt->context->node = bak;
+ CHECK_ERROR0;
+ }
return (total);
case XPATH_OP_PREDICATE:
case XPATH_OP_FILTER:{
@@ -10594,7 +10595,7 @@
xmlLocationSetPtr newlocset = NULL;
xmlLocationSetPtr oldlocset;
xmlNodeSetPtr oldset;
- int i;
+ int i, j;
if (op->ch1 != -1)
total +=
@@ -10611,9 +10612,9 @@
CHECK_TYPE0(XPATH_LOCATIONSET);
obj = valuePop(ctxt);
oldlocset = obj->user;
- ctxt->context->node = NULL;
if ((oldlocset == NULL) || (oldlocset->locNr == 0)) {
+ ctxt->context->node = NULL;
ctxt->context->contextSize = 0;
ctxt->context->proximityPosition = 0;
total += xmlXPathCompOpEval(ctxt,&comp->steps[op->ch2]);
@@ -10631,11 +10632,11 @@
* Run the evaluation with a node list made of a
* single item in the nodelocset.
*/
- ctxt->context->node = oldlocset->locTab[i]->user;
+ ctxt->context->node = (xmlNodePtr)ctxt->context->doc;
+ ctxt->context->contextSize = 1;
+ ctxt->context->proximityPosition = 1;
tmp = xmlXPathNewNodeSet(ctxt->context->node);
valuePush(ctxt, tmp);
- ctxt->context->contextSize = oldlocset->locNr;
- ctxt->context->proximityPosition = i + 1;
if (op->ch2 != -1)
total +=
@@ -10644,14 +10645,29 @@
CHECK_ERROR0;
/*
- * The result of the evaluation need to be tested to
- * decided whether the filter succeeded or not
+ * The result of the evaluation needs to be tested to
+ * decide whether the filter succeeded or not
*/
res = valuePop(ctxt);
- if (xmlXPathEvaluatePredicateResult(ctxt, res)) {
- xmlXPtrLocationSetAdd(newlocset,
- xmlXPathObjectCopy
- (oldlocset->locTab[i]));
+ if (res->type == XPATH_LOCATIONSET) {
+ xmlLocationSetPtr rloc =
+ (xmlLocationSetPtr)res->user;
+ for (j=0; j<rloc->locNr; j++) {
+ range = xmlXPtrNewRange(
+ oldlocset->locTab[i]->user,
+ oldlocset->locTab[i]->index,
+ rloc->locTab[j]->user2,
+ rloc->locTab[j]->index2);
+ if (range != NULL) {
+ xmlXPtrLocationSetAdd(newlocset, range);
+ }
+ }
+ } else {
+ range = xmlXPtrNewRangeNodeObject(
+ (xmlNodePtr)oldlocset->locTab[i]->user, res);
+ if (range != NULL) {
+ xmlXPtrLocationSetAdd(newlocset,range);
+ }
}
/*
@@ -10666,7 +10682,7 @@
ctxt->context->node = NULL;
}
- } else { /* Not a location set */
+ } else { /* Not a location set */
CHECK_TYPE0(XPATH_NODESET);
obj = valuePop(ctxt);
oldset = obj->nodesetval;