diff options
author | Mike Hommey <glandium@debian.org> | 2007-04-17 20:40:00 +0200 |
---|---|---|
committer | Mike Hommey <glandium@debian.org> | 2007-04-17 20:40:00 +0200 |
commit | 789259a1b6850d30acffbb62b11456b9ed7a8f59 (patch) | |
tree | 842f2f9042a4264898ec29078aa029640078c393 /xpath.c | |
parent | 968041a8b2ec86c39b5074024ce97d136ecd9a95 (diff) | |
download | libxml2-789259a1b6850d30acffbb62b11456b9ed7a8f59.tar.gz |
Load /tmp/libxml2-2.6.28 intoupstream/2.6.28.dfsg
libxml2/branches/upstream/current.
Diffstat (limited to 'xpath.c')
-rw-r--r-- | xpath.c | 36 |
1 files changed, 27 insertions, 9 deletions
@@ -198,6 +198,7 @@ static xmlNs xmlXPathXMLNamespaceStruct = { XML_NAMESPACE_DECL, XML_XML_NAMESPACE, BAD_CAST "xml", + NULL, NULL }; static xmlNsPtr xmlXPathXMLNamespace = &xmlXPathXMLNamespaceStruct; @@ -2840,6 +2841,8 @@ xmlXPathCmpNodes(xmlNodePtr node1, xmlNodePtr node2) { /* * a couple of optimizations which will avoid computations in most cases */ + if (node1 == node2) /* trivial case */ + return(0); if (node1->type == XML_ATTRIBUTE_NODE) { attr1 = 1; attrNode1 = node1; @@ -7668,9 +7671,9 @@ xmlXPathNextDescendantOrSelfElemParent(xmlNodePtr cur, continue; } break; -#ifdef LIBXML_DOCB_ENABLED /* Not sure if we need those here. */ case XML_DOCUMENT_NODE: +#ifdef LIBXML_DOCB_ENABLED case XML_DOCB_DOCUMENT_NODE: #endif case XML_HTML_DOCUMENT_NODE: @@ -11544,8 +11547,11 @@ xmlXPathCompOpEvalPredicate(xmlXPathParserContextPtr ctxt, res = xmlXPathCompOpEvalToBoolean(ctxt, exprOp, 1); - if ((ctxt->error != XPATH_EXPRESSION_OK) || (res == -1)) - goto evaluation_error; + if ((ctxt->error != XPATH_EXPRESSION_OK) || (res == -1)) { + xmlXPathNodeSetClear(set, hasNsNodes); + newContextSize = 0; + goto evaluation_exit; + } if (res != 0) { newContextSize++; @@ -11573,18 +11579,13 @@ xmlXPathCompOpEvalPredicate(xmlXPathParserContextPtr ctxt, contextObj = NULL; } } - goto evaluation_exit; -evaluation_error: - xmlXPathNodeSetClear(set, hasNsNodes); - newContextSize = 0; - -evaluation_exit: if (contextObj != NULL) { if (ctxt->value == contextObj) valuePop(ctxt); xmlXPathReleaseObject(xpctxt, contextObj); } +evaluation_exit: if (exprRes != NULL) xmlXPathReleaseObject(ctxt->context, exprRes); /* @@ -12163,6 +12164,7 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt, #ifdef DEBUG_STEP xmlGenericError(xmlGenericErrorContext, " %s", cur->name); #endif + switch (test) { case NODE_TEST_NONE: total = 0; @@ -12241,6 +12243,16 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt, break; } case NODE_TEST_NAME: + if (axis == AXIS_ATTRIBUTE) { + if (cur->type != XML_ATTRIBUTE_NODE) + break; + } else if (axis == AXIS_NAMESPACE) { + if (cur->type != XML_NAMESPACE_DECL) + break; + } else { + if (cur->type != XML_ELEMENT_NODE) + break; + } switch (cur->type) { case XML_ELEMENT_NODE: if (xmlStrEqual(name, cur->name)) { @@ -14543,6 +14555,8 @@ xmlXPathCtxtCompile(xmlXPathContextPtr ctxt, const xmlChar *str) { xmlXPathInit(); pctxt = xmlXPathNewParserContext(str, ctxt); + if (pctxt == NULL) + return NULL; xmlXPathCompileExpr(pctxt, 1); if( pctxt->error != XPATH_EXPRESSION_OK ) @@ -14794,6 +14808,8 @@ xmlXPathEval(const xmlChar *str, xmlXPathContextPtr ctx) { xmlXPathInit(); ctxt = xmlXPathNewParserContext(str, ctx); + if (ctxt == NULL) + return NULL; xmlXPathEvalExpr(ctxt); if (ctxt->value == NULL) { @@ -14854,6 +14870,8 @@ xmlXPathEvalExpression(const xmlChar *str, xmlXPathContextPtr ctxt) { xmlXPathInit(); pctxt = xmlXPathNewParserContext(str, ctxt); + if (pctxt == NULL) + return NULL; xmlXPathEvalExpr(pctxt); if ((*pctxt->cur != 0) || (pctxt->error != XPATH_EXPRESSION_OK)) { |