On 21/03/2014 12:13, Vojtech Fried wrote:
Hi,
In our app, we use libxml2 and we connect XPath variables to our proprietary
script language and its variables. I have recently noticed a possible bug with
it. To replicate the issue, I have created an xslt. Handling of variables is a
bit grey zone for me, but I think there has to be a bug somewhere in libxml2.
...
I would expect to have “item” element also in test1, test3 and test4. The
string lengths are 4 or 2 (see l1, l2, l3, l4). There are four elements in
$array, see “cnt” element. I have tried it with ms xslt and the “item”
elements are there as I would expect.
The attached patch fixes the issue for me.
Nick
>From 191f64312ff85ce9df0d2bac14ec1d89759c05d1 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnho...@aevum.de>
Date: Fri, 21 Mar 2014 19:38:08 +0100
Subject: [PATCH] Restore context size and position after XPATH_OP_ARG
---
xpath.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/xpath.c b/xpath.c
index 89eaba8..c754237 100644
--- a/xpath.c
+++ b/xpath.c
@@ -13594,19 +13594,18 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt,
xmlXPathStepOpPtr op)
bak = ctxt->context->node;
pp = ctxt->context->proximityPosition;
cs = ctxt->context->contextSize;
- if (op->ch1 != -1)
+ if (op->ch1 != -1) {
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
- ctxt->context->contextSize = cs;
- ctxt->context->proximityPosition = pp;
- ctxt->context->node = bak;
- ctxt->context->doc = bakd;
- CHECK_ERROR0;
+ CHECK_ERROR0;
+ }
if (op->ch2 != -1) {
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
- ctxt->context->doc = bakd;
- ctxt->context->node = bak;
CHECK_ERROR0;
}
+ ctxt->context->contextSize = cs;
+ ctxt->context->proximityPosition = pp;
+ ctxt->context->node = bak;
+ ctxt->context->doc = bakd;
return (total);
case XPATH_OP_PREDICATE:
case XPATH_OP_FILTER:{
--
1.8.3.2
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml