summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2016-04-27 18:00:12 +0200
committerNick Wellnhofer <wellnhofer@aevum.de>2016-04-27 18:05:06 +0200
commit839689a9a85d81f722997d00ec17a36b17ce6731 (patch)
tree36c9496b280bc0c2a9335718ecdde04937c69b95
parentf39fd66ea768802665e0a010f4be408ef9c69bcf (diff)
downloadlibxml2-839689a9a85d81f722997d00ec17a36b17ce6731.tar.gz
Don't recurse into OP_VALUEs in xmlXPathOptimizeExpression
The ch1 slot of OP_VALUEs contains an invalid value. Ignore it. Fixes bug #760325: https://bugzilla.gnome.org/show_bug.cgi?id=760325
-rw-r--r--result/XPath/expr/base4
-rw-r--r--test/XPath/expr/base1
-rw-r--r--xpath.c4
3 files changed, 9 insertions, 0 deletions
diff --git a/result/XPath/expr/base b/result/XPath/expr/base
index d308a920..e04346fa 100644
--- a/result/XPath/expr/base
+++ b/result/XPath/expr/base
@@ -20,5 +20,9 @@ Expression: (1+2)*(3+4)
Object is a number : 21
========================
+Expression: 1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1
+Object is a number : 21
+
+========================
Expression: self::-name
Object is empty (NULL)
diff --git a/test/XPath/expr/base b/test/XPath/expr/base
index 0be4871e..f57e4d0c 100644
--- a/test/XPath/expr/base
+++ b/test/XPath/expr/base
@@ -3,4 +3,5 @@
2*3
1+2*3+4
(1+2)*(3+4)
+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1+1*1
self::-name
diff --git a/xpath.c b/xpath.c
index 6b92e7de..39240509 100644
--- a/xpath.c
+++ b/xpath.c
@@ -14786,6 +14786,10 @@ xmlXPathOptimizeExpression(xmlXPathCompExprPtr comp, xmlXPathStepOpPtr op)
}
}
+ /* OP_VALUE has invalid ch1. */
+ if (op->op == XPATH_OP_VALUE)
+ return;
+
/* Recurse */
if (op->ch1 != -1)
xmlXPathOptimizeExpression(comp, &comp->steps[op->ch1]);