diff options
Diffstat (limited to 'xpointer.c')
-rw-r--r-- | xpointer.c | 38 |
1 files changed, 26 insertions, 12 deletions
@@ -14,6 +14,11 @@ * daniel@veillard.com */ +/* To avoid EBCDIC trouble when parsing on zOS */ +#if defined(__MVS__) +#pragma convert("ISO8859-1") +#endif + #define IN_LIBXML #include "libxml.h" @@ -99,6 +104,10 @@ xmlXPtrErr(xmlXPathParserContextPtr ctxt, int error, msg, extra); return; } + + /* cleanup current last error */ + xmlResetError(&ctxt->context->lastError); + ctxt->context->lastError.domain = XML_FROM_XPOINTER; ctxt->context->lastError.code = error; ctxt->context->lastError.level = XML_ERR_ERROR; @@ -458,8 +467,6 @@ xmlXPtrNewRangeNodePoint(xmlNodePtr start, xmlXPathObjectPtr end) { return(NULL); if (end == NULL) return(NULL); - if (start->type != XPATH_POINT) - return(NULL); if (end->type != XPATH_POINT) return(NULL); @@ -542,7 +549,7 @@ xmlXPtrNewRangeNodeObject(xmlNodePtr start, xmlXPathObjectPtr end) { /* * Empty set ... */ - if (end->nodesetval->nodeNr <= 0) + if ((end->nodesetval == NULL) || (end->nodesetval->nodeNr <= 0)) return(NULL); endNode = end->nodesetval->nodeTab[end->nodesetval->nodeNr - 1]; endIndex = -1; @@ -949,8 +956,10 @@ xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) { if (name == NULL) XP_ERROR(XPATH_EXPR_ERROR); - if (CUR != '(') + if (CUR != '(') { + xmlFree(name); XP_ERROR(XPATH_EXPR_ERROR); + } NEXT; level = 1; @@ -959,6 +968,7 @@ xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) { buffer = (xmlChar *) xmlMallocAtomic(len * sizeof (xmlChar)); if (buffer == NULL) { xmlXPtrErrMemory("allocating buffer"); + xmlFree(name); return; } @@ -983,6 +993,7 @@ xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) { *cur = 0; if ((level != 0) && (CUR == 0)) { + xmlFree(name); xmlFree(buffer); XP_ERROR(XPTR_SYNTAX_ERROR); } @@ -1015,6 +1026,7 @@ xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) { if (name2 == NULL) { CUR_PTR = left; xmlFree(buffer); + xmlFree(name); XP_ERROR(XPATH_EXPR_ERROR); } xmlXPtrEvalChildSeq(ctxt, name2); @@ -1361,7 +1373,7 @@ xmlXPtrEval(const xmlChar *str, xmlXPathContextPtr ctx) { */ xmlNodeSetPtr set; set = tmp->nodesetval; - if ((set->nodeNr != 1) || + if ((set == NULL) || (set->nodeNr != 1) || (set->nodeTab[0] != (xmlNodePtr) ctx->doc)) stack++; } else @@ -1796,8 +1808,8 @@ xmlXPtrStartPointFunction(xmlXPathParserContextPtr ctxt, int nargs) { case XPATH_RANGE: { xmlNodePtr node = tmp->user; if (node != NULL) { - if (node->type == XML_ATTRIBUTE_NODE) { - /* TODO: Namespace Nodes ??? */ + if ((node->type == XML_ATTRIBUTE_NODE) || + (node->type == XML_NAMESPACE_DECL)) { xmlXPathFreeObject(obj); xmlXPtrFreeLocationSet(newset); XP_ERROR(XPTR_SYNTAX_ERROR); @@ -1892,8 +1904,8 @@ xmlXPtrEndPointFunction(xmlXPathParserContextPtr ctxt, int nargs) { case XPATH_RANGE: { xmlNodePtr node = tmp->user2; if (node != NULL) { - if (node->type == XML_ATTRIBUTE_NODE) { - /* TODO: Namespace Nodes ??? */ + if ((node->type == XML_ATTRIBUTE_NODE) || + (node->type == XML_NAMESPACE_DECL)) { xmlXPathFreeObject(obj); xmlXPtrFreeLocationSet(newset); XP_ERROR(XPTR_SYNTAX_ERROR); @@ -2034,9 +2046,11 @@ xmlXPtrRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathFreeObject(set); XP_ERROR(XPATH_MEMORY_ERROR); } - for (i = 0;i < oldset->locNr;i++) { - xmlXPtrLocationSetAdd(newset, - xmlXPtrCoveringRange(ctxt, oldset->locTab[i])); + if (oldset != NULL) { + for (i = 0;i < oldset->locNr;i++) { + xmlXPtrLocationSetAdd(newset, + xmlXPtrCoveringRange(ctxt, oldset->locTab[i])); + } } /* |