From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Sun, 4 Aug 2013 22:15:11 +0000
Subject: Fix XPath '//' optimization with predicates

My attempt to optimize XPath expressions containing '//' caused a
regression reported in bug #695699. This commit disables the
optimization for expressions of the form '//foo[predicate]'.
---
 xpath.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/xpath.c b/xpath.c
index 97410e7..a676989 100644
--- a/xpath.c
+++ b/xpath.c
@@ -14719,8 +14719,9 @@ xmlXPathOptimizeExpression(xmlXPathCompExprPtr comp, xmlXPathStepOpPtr op)
     * internal representation.
     */
 
-    if ((op->ch1 != -1) &&
-        (op->op == XPATH_OP_COLLECT /* 11 */))
+    if ((op->op == XPATH_OP_COLLECT /* 11 */) &&
+        (op->ch1 != -1) &&
+        (op->ch2 == -1 /* no predicate */))
     {
         xmlXPathStepOpPtr prevop = &comp->steps[op->ch1];
 
