diff options
Diffstat (limited to 'xpath.c')
-rw-r--r-- | xpath.c | 44 |
1 files changed, 32 insertions, 12 deletions
@@ -639,7 +639,7 @@ xmlXPathErrMemory(xmlXPathContextPtr ctxt, const char *extra) xmlChar buf[200]; xmlStrPrintf(buf, 200, - BAD_CAST "Memory allocation failed : %s\n", + "Memory allocation failed : %s\n", extra); ctxt->lastError.message = (char *) xmlStrdup(buf); } else { @@ -945,7 +945,7 @@ struct _xmlXPathCompExpr { xmlXPathStepOp *steps; /* ops for computation of this expression */ int last; /* index of last step in expression */ xmlChar *expr; /* the expression being computed */ - xmlDictPtr dict; /* the dictionnary to use if any */ + xmlDictPtr dict; /* the dictionary to use if any */ #ifdef DEBUG_EVAL_COUNTS int nb; xmlChar *string; @@ -3706,7 +3706,7 @@ xmlXPathNodeSetAdd(xmlNodeSetPtr cur, xmlNodePtr val) { /* @@ with_ns to check whether namespace nodes should be looked at @@ */ /* - * prevent duplcates + * prevent duplicates */ for (i = 0;i < cur->nodeNr;i++) if (cur->nodeTab[i] == val) return(0); @@ -8390,7 +8390,7 @@ xmlNodePtr xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) { if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL); if (ctxt->context->node->type != XML_ELEMENT_NODE) return(NULL); - if (ctxt->context->tmpNsList == NULL && cur != (xmlNodePtr) xmlXPathXMLNamespace) { + if (cur == NULL) { if (ctxt->context->tmpNsList != NULL) xmlFree(ctxt->context->tmpNsList); ctxt->context->tmpNsList = @@ -9996,7 +9996,7 @@ xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt, int qualified) { (c == '[') || (c == ']') || (c == '@') || /* accelerators */ (c == '*') || /* accelerators */ (!IS_LETTER(c) && (c != '_') && - ((qualified) && (c != ':')))) { + ((!qualified) || (c != ':')))) { return(NULL); } @@ -12379,11 +12379,6 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt, STRANGE goto error; case NODE_TEST_TYPE: - /* - * TODO: Don't we need to use - * xmlXPathNodeSetAddNs() for namespace nodes here? - * Surprisingly, some c14n tests fail, if we do this. - */ if (type == NODE_TYPE_NODE) { switch (cur->type) { case XML_DOCUMENT_NODE: @@ -12397,9 +12392,17 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt, case XML_COMMENT_NODE: case XML_CDATA_SECTION_NODE: case XML_TEXT_NODE: - case XML_NAMESPACE_DECL: XP_TEST_HIT break; + case XML_NAMESPACE_DECL: { + if (axis == AXIS_NAMESPACE) { + XP_TEST_HIT_NS + } else { + hasNsNodes = 1; + XP_TEST_HIT + } + break; + } default: break; } @@ -12691,6 +12694,14 @@ error: * Reset the context node. */ xpctxt->node = oldContextNode; + /* + * When traversing the namespace axis in "toBool" mode, it's + * possible that tmpNsList wasn't freed. + */ + if (xpctxt->tmpNsList != NULL) { + xmlFree(xpctxt->tmpNsList); + xpctxt->tmpNsList = NULL; + } #ifdef DEBUG_STEP xmlGenericError(xmlGenericErrorContext, @@ -13994,9 +14005,14 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op) xmlNodeSetPtr oldset; int i, j; - if (op->ch1 != -1) + if (op->ch1 != -1) { total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); + CHECK_ERROR0; + } + if (ctxt->value == NULL) { + XP_ERROR0(XPATH_INVALID_OPERAND); + } if (op->ch2 == -1) return (total); @@ -14784,6 +14800,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]); |