Fixed an error in xmlXPathEvalExpr(), which was introduced with the
* xpath.c: Fixed an error in xmlXPathEvalExpr(), which
was introduced with the addition of the d-o-s rewrite
and made xpath.c unable to compile if XPATH_STREAMING
was not defined (reported by Kupriyanov Anatolij -
#345752). Fixed the check for d-o-s rewrite
to work on the correct XPath string, which is ctxt->base
and not comp->expr in this case.
diff --git a/ChangeLog b/ChangeLog
index b9bf348..41f0816 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Fri Jun 23 18:26:08 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+ * xpath.c: Fixed an error in xmlXPathEvalExpr(), which
+ was introduced with the addition of the d-o-s rewrite
+ and made xpath.c unable to compile if XPATH_STREAMING
+ was not defined (reported by Kupriyanov Anatolij -
+ #345752). Fixed the check for d-o-s rewrite
+ to work on the correct XPath string, which is ctxt->base
+ and not comp->expr in this case.
+
Mon Jun 19 12:23:41 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
* xpath.c: Added optimization for positional predicates
diff --git a/xpath.c b/xpath.c
index 1e7f8e6..ff2f2da 100644
--- a/xpath.c
+++ b/xpath.c
@@ -14404,13 +14404,14 @@
#ifdef DEBUG_EVAL_COUNTS
comp->string = xmlStrdup(str);
comp->nb = 0;
-#endif
- if ((comp->nbStep > 2) &&
+#endif
+ if ((comp->expr != NULL) &&
+ (comp->nbStep > 2) &&
+ (comp->last >= 0) &&
(xmlXPathCanRewriteDosExpression(comp->expr) == 1))
{
xmlXPathRewriteDOSExpression(comp, &comp->steps[comp->last]);
}
-
}
return(comp);
}
@@ -14531,12 +14532,18 @@
#endif
{
xmlXPathCompileExpr(ctxt, 1);
- if ((ctxt->comp != NULL) &&
+ /*
+ * In this scenario the expression string will sit in ctxt->base.
+ */
+ if ((ctxt->error == XPATH_EXPRESSION_OK) &&
+ (ctxt->comp != NULL) &&
+ (ctxt->base != NULL) &&
(ctxt->comp->nbStep > 2) &&
- (xmlXPathCanRewriteDosExpression(ctxt->comp->expr) == 1))
+ (ctxt->comp->last >= 0) &&
+ (xmlXPathCanRewriteDosExpression((xmlChar *) ctxt->base) == 1))
{
xmlXPathRewriteDOSExpression(ctxt->comp,
- &ctxt->comp->steps[comp->last]);
+ &ctxt->comp->steps[ctxt->comp->last]);
}
}
CHECK_ERROR;