From effb43a066e70763fa89eb7142b7cb7b428694ad Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Wed, 22 Jun 2016 14:10:16 +0900 Subject: Imported Upstream version 1.1.29 Change-Id: I7d894ba27f8f8e886dbcece3bb3df8e69059cae9 Signed-off-by: DongHun Kwak --- libexslt/dynamic.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'libexslt/dynamic.c') diff --git a/libexslt/dynamic.c b/libexslt/dynamic.c index e0bfe817..7b95fc5e 100644 --- a/libexslt/dynamic.c +++ b/libexslt/dynamic.c @@ -167,10 +167,27 @@ exsltDynMapFunction(xmlXPathParserContextPtr ctxt, int nargs) ctxt->context->proximityPosition = 0; for (i = 0; i < nodeset->nodeNr; i++) { xmlXPathObjectPtr subResult = NULL; + xmlNodePtr cur = nodeset->nodeTab[i]; ctxt->context->proximityPosition++; - ctxt->context->node = nodeset->nodeTab[i]; - ctxt->context->doc = nodeset->nodeTab[i]->doc; + ctxt->context->node = cur; + + if (cur->type == XML_NAMESPACE_DECL) { + /* + * The XPath module sets the owner element of a ns-node on + * the ns->next field. + */ + cur = (xmlNodePtr) ((xmlNsPtr) cur)->next; + if ((cur == NULL) || (cur->type != XML_ELEMENT_NODE)) { + xsltGenericError(xsltGenericErrorContext, + "Internal error in exsltDynMapFunction: " + "Cannot retrieve the doc of a namespace node.\n"); + continue; + } + ctxt->context->doc = cur->doc; + } else { + ctxt->context->doc = cur->doc; + } subResult = xmlXPathCompiledEval(comp, ctxt->context); if (subResult != NULL) { -- cgit v1.2.3