mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-20 18:50:08 +03:00
parser: Improve error handling
Introduce xmlCtxtSetErrorHandler allowing to set a structured error for a parser context. There already was the "serror" SAX handler but this always receives the parser context as argument. Start to use xmlRaiseMemoryError. Remove useless arguments from memory error functions. Rename xmlErrMemory to xmlCtxtErrMemory. Remove a few calls to xmlGenericError. Remove support for runtime entity debugging.
This commit is contained in:
parent
c5a8aef2f6
commit
54c70ed57f
60
HTMLparser.c
60
HTMLparser.c
@ -58,9 +58,9 @@ static void htmlParseComment(htmlParserCtxtPtr ctxt);
|
||||
* Handle a redefinition of attribute error
|
||||
*/
|
||||
static void
|
||||
htmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
|
||||
htmlErrMemory(xmlParserCtxtPtr ctxt)
|
||||
{
|
||||
xmlErrMemory(ctxt, extra);
|
||||
xmlCtxtErrMemory(ctxt);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -127,7 +127,7 @@ htmlnamePush(htmlParserCtxtPtr ctxt, const xmlChar * value)
|
||||
tmp = xmlRealloc((xmlChar **) ctxt->nameTab,
|
||||
newSize * sizeof(ctxt->nameTab[0]));
|
||||
if (tmp == NULL) {
|
||||
htmlErrMemory(ctxt, NULL);
|
||||
htmlErrMemory(ctxt);
|
||||
return (-1);
|
||||
}
|
||||
ctxt->nameTab = tmp;
|
||||
@ -185,7 +185,7 @@ htmlNodeInfoPush(htmlParserCtxtPtr ctxt, htmlParserNodeInfo *value)
|
||||
ctxt->nodeInfoMax *
|
||||
sizeof(ctxt->nodeInfoTab[0]));
|
||||
if (ctxt->nodeInfoTab == NULL) {
|
||||
htmlErrMemory(ctxt, NULL);
|
||||
htmlErrMemory(ctxt);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
@ -343,7 +343,7 @@ htmlFindEncoding(xmlParserCtxtPtr ctxt) {
|
||||
return(NULL);
|
||||
ret = xmlStrndup(start, cur - start);
|
||||
if (ret == NULL)
|
||||
htmlErrMemory(ctxt, NULL);
|
||||
htmlErrMemory(ctxt);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@ -1996,7 +1996,7 @@ static const htmlEntityDesc html40EntitiesTable[] = {
|
||||
buffer##_size *= 2; \
|
||||
tmp = (xmlChar *) xmlRealloc(buffer, buffer##_size); \
|
||||
if (tmp == NULL) { \
|
||||
htmlErrMemory(ctxt, "growing buffer\n"); \
|
||||
htmlErrMemory(ctxt); \
|
||||
xmlFree(buffer); \
|
||||
return(NULL); \
|
||||
} \
|
||||
@ -2273,7 +2273,7 @@ htmlNewInputStream(htmlParserCtxtPtr ctxt) {
|
||||
|
||||
input = (xmlParserInputPtr) xmlMalloc(sizeof(htmlParserInput));
|
||||
if (input == NULL) {
|
||||
htmlErrMemory(ctxt, "couldn't allocate a new input stream\n");
|
||||
htmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
memset(input, 0, sizeof(htmlParserInput));
|
||||
@ -2518,7 +2518,7 @@ htmlParseHTMLName(htmlParserCtxtPtr ctxt) {
|
||||
|
||||
ret = xmlDictLookup(ctxt->dict, loc, i);
|
||||
if (ret == NULL)
|
||||
htmlErrMemory(ctxt, NULL);
|
||||
htmlErrMemory(ctxt);
|
||||
|
||||
return(ret);
|
||||
}
|
||||
@ -2554,7 +2554,7 @@ htmlParseHTMLName_nonInvasive(htmlParserCtxtPtr ctxt) {
|
||||
|
||||
ret = xmlDictLookup(ctxt->dict, loc, i);
|
||||
if (ret == NULL)
|
||||
htmlErrMemory(ctxt, NULL);
|
||||
htmlErrMemory(ctxt);
|
||||
|
||||
return(ret);
|
||||
}
|
||||
@ -2599,7 +2599,7 @@ htmlParseName(htmlParserCtxtPtr ctxt) {
|
||||
count = in - ctxt->input->cur;
|
||||
ret = xmlDictLookup(ctxt->dict, ctxt->input->cur, count);
|
||||
if (ret == NULL)
|
||||
htmlErrMemory(ctxt, NULL);
|
||||
htmlErrMemory(ctxt);
|
||||
ctxt->input->cur = in;
|
||||
ctxt->input->col += count;
|
||||
return(ret);
|
||||
@ -2659,7 +2659,7 @@ htmlParseNameComplex(xmlParserCtxtPtr ctxt) {
|
||||
|
||||
ret = xmlDictLookup(ctxt->dict, ctxt->input->cur - len, len);
|
||||
if (ret == NULL)
|
||||
htmlErrMemory(ctxt, NULL);
|
||||
htmlErrMemory(ctxt);
|
||||
|
||||
return(ret);
|
||||
}
|
||||
@ -2694,7 +2694,7 @@ htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
|
||||
buffer_size = HTML_PARSER_BUFFER_SIZE;
|
||||
buffer = (xmlChar *) xmlMallocAtomic(buffer_size);
|
||||
if (buffer == NULL) {
|
||||
htmlErrMemory(ctxt, "buffer allocation failed\n");
|
||||
htmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
out = buffer;
|
||||
@ -2959,7 +2959,7 @@ htmlParseSystemLiteral(htmlParserCtxtPtr ctxt) {
|
||||
if (err == 0) {
|
||||
ret = xmlStrndup((BASE_PTR+startPosition), len);
|
||||
if (ret == NULL) {
|
||||
htmlErrMemory(ctxt, NULL);
|
||||
htmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
@ -3020,7 +3020,7 @@ htmlParsePubidLiteral(htmlParserCtxtPtr ctxt) {
|
||||
if (err == 0) {
|
||||
ret = xmlStrndup((BASE_PTR + startPosition), len);
|
||||
if (ret == NULL) {
|
||||
htmlErrMemory(ctxt, NULL);
|
||||
htmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
@ -3330,7 +3330,7 @@ htmlParsePI(htmlParserCtxtPtr ctxt) {
|
||||
}
|
||||
buf = (xmlChar *) xmlMallocAtomic(size);
|
||||
if (buf == NULL) {
|
||||
htmlErrMemory(ctxt, NULL);
|
||||
htmlErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
cur = CUR;
|
||||
@ -3347,7 +3347,7 @@ htmlParsePI(htmlParserCtxtPtr ctxt) {
|
||||
size *= 2;
|
||||
tmp = (xmlChar *) xmlRealloc(buf, size);
|
||||
if (tmp == NULL) {
|
||||
htmlErrMemory(ctxt, NULL);
|
||||
htmlErrMemory(ctxt);
|
||||
xmlFree(buf);
|
||||
return;
|
||||
}
|
||||
@ -3428,7 +3428,7 @@ htmlParseComment(htmlParserCtxtPtr ctxt) {
|
||||
SKIP(4);
|
||||
buf = (xmlChar *) xmlMallocAtomic(size);
|
||||
if (buf == NULL) {
|
||||
htmlErrMemory(ctxt, "buffer allocation failed\n");
|
||||
htmlErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
len = 0;
|
||||
@ -3472,7 +3472,7 @@ htmlParseComment(htmlParserCtxtPtr ctxt) {
|
||||
tmp = (xmlChar *) xmlRealloc(buf, size);
|
||||
if (tmp == NULL) {
|
||||
xmlFree(buf);
|
||||
htmlErrMemory(ctxt, "growing buffer failed\n");
|
||||
htmlErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
buf = tmp;
|
||||
@ -3746,7 +3746,7 @@ htmlCheckEncoding(htmlParserCtxtPtr ctxt, const xmlChar *attvalue) {
|
||||
encoding ++;
|
||||
copy = xmlStrdup(encoding);
|
||||
if (copy == NULL)
|
||||
htmlErrMemory(ctxt, NULL);
|
||||
htmlErrMemory(ctxt);
|
||||
xmlSetDeclaredEncoding(ctxt, copy);
|
||||
}
|
||||
}
|
||||
@ -3781,7 +3781,7 @@ htmlCheckMeta(htmlParserCtxtPtr ctxt, const xmlChar **atts) {
|
||||
|
||||
copy = xmlStrdup(value);
|
||||
if (copy == NULL)
|
||||
htmlErrMemory(ctxt, NULL);
|
||||
htmlErrMemory(ctxt);
|
||||
xmlSetDeclaredEncoding(ctxt, copy);
|
||||
} else if (!xmlStrcasecmp(att, BAD_CAST "content")) {
|
||||
content = value;
|
||||
@ -3926,7 +3926,7 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) {
|
||||
atts = (const xmlChar **)
|
||||
xmlMalloc(maxatts * sizeof(xmlChar *));
|
||||
if (atts == NULL) {
|
||||
htmlErrMemory(ctxt, NULL);
|
||||
htmlErrMemory(ctxt);
|
||||
if (attvalue != NULL)
|
||||
xmlFree(attvalue);
|
||||
goto failed;
|
||||
@ -3940,7 +3940,7 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) {
|
||||
n = (const xmlChar **) xmlRealloc((void *) atts,
|
||||
maxatts * sizeof(const xmlChar *));
|
||||
if (n == NULL) {
|
||||
htmlErrMemory(ctxt, NULL);
|
||||
htmlErrMemory(ctxt);
|
||||
if (attvalue != NULL)
|
||||
xmlFree(attvalue);
|
||||
goto failed;
|
||||
@ -4591,7 +4591,7 @@ htmlParseContentInternal(htmlParserCtxtPtr ctxt) {
|
||||
} else {
|
||||
currentNode = xmlStrdup(ctxt->name);
|
||||
if (currentNode == NULL) {
|
||||
htmlErrMemory(ctxt, NULL);
|
||||
htmlErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -4613,7 +4613,7 @@ htmlParseContentInternal(htmlParserCtxtPtr ctxt) {
|
||||
} else {
|
||||
currentNode = xmlStrdup(ctxt->name);
|
||||
if (currentNode == NULL) {
|
||||
htmlErrMemory(ctxt, NULL);
|
||||
htmlErrMemory(ctxt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -4642,7 +4642,7 @@ htmlParseContentInternal(htmlParserCtxtPtr ctxt) {
|
||||
} else {
|
||||
currentNode = xmlStrdup(ctxt->name);
|
||||
if (currentNode == NULL) {
|
||||
htmlErrMemory(ctxt, NULL);
|
||||
htmlErrMemory(ctxt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -4673,7 +4673,7 @@ htmlParseContentInternal(htmlParserCtxtPtr ctxt) {
|
||||
} else {
|
||||
currentNode = xmlStrdup(ctxt->name);
|
||||
if (currentNode == NULL) {
|
||||
htmlErrMemory(ctxt, NULL);
|
||||
htmlErrMemory(ctxt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -4732,7 +4732,7 @@ htmlParseContentInternal(htmlParserCtxtPtr ctxt) {
|
||||
} else {
|
||||
currentNode = xmlStrdup(ctxt->name);
|
||||
if (currentNode == NULL) {
|
||||
htmlErrMemory(ctxt, NULL);
|
||||
htmlErrMemory(ctxt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -4901,7 +4901,7 @@ htmlParseDocument(htmlParserCtxtPtr ctxt) {
|
||||
BAD_CAST "-//W3C//DTD HTML 4.0 Transitional//EN",
|
||||
BAD_CAST "http://www.w3.org/TR/REC-html40/loose.dtd");
|
||||
if (ctxt->myDoc->intSubset == NULL)
|
||||
htmlErrMemory(ctxt, NULL);
|
||||
htmlErrMemory(ctxt);
|
||||
}
|
||||
}
|
||||
if (! ctxt->wellFormed) return(-1);
|
||||
@ -5786,7 +5786,7 @@ done:
|
||||
BAD_CAST "-//W3C//DTD HTML 4.0 Transitional//EN",
|
||||
BAD_CAST "http://www.w3.org/TR/REC-html40/loose.dtd");
|
||||
if (ctxt->myDoc->intSubset == NULL)
|
||||
htmlErrMemory(ctxt, NULL);
|
||||
htmlErrMemory(ctxt);
|
||||
}
|
||||
}
|
||||
return(ret);
|
||||
@ -6722,7 +6722,7 @@ htmlCtxtReadMemory(htmlParserCtxtPtr ctxt, const char *buffer, int size,
|
||||
input = xmlParserInputBufferCreateStatic(buffer, size,
|
||||
XML_CHAR_ENCODING_NONE);
|
||||
if (input == NULL) {
|
||||
htmlErrMemory(ctxt, NULL);
|
||||
htmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
135
SAX2.c
135
SAX2.c
@ -31,29 +31,14 @@
|
||||
#include "private/parser.h"
|
||||
#include "private/tree.h"
|
||||
|
||||
/**
|
||||
* TODO:
|
||||
*
|
||||
* macro to flag unimplemented blocks
|
||||
* XML_CATALOG_PREFER user env to select between system/public preferred
|
||||
* option. C.f. Richard Tobin <richard@cogsci.ed.ac.uk>
|
||||
*> Just FYI, I am using an environment variable XML_CATALOG_PREFER with
|
||||
*> values "system" and "public". I have made the default be "system" to
|
||||
*> match yours.
|
||||
*/
|
||||
#define TODO \
|
||||
xmlGenericError(xmlGenericErrorContext, \
|
||||
"Unimplemented block at %s:%d\n", \
|
||||
__FILE__, __LINE__);
|
||||
|
||||
/*
|
||||
* xmlSAX2ErrMemory:
|
||||
* @ctxt: an XML validation parser context
|
||||
* @msg: a string to accompany the error message
|
||||
*/
|
||||
static void LIBXML_ATTR_FORMAT(2,0)
|
||||
xmlSAX2ErrMemory(xmlParserCtxtPtr ctxt, const char *msg) {
|
||||
xmlErrMemory(ctxt, msg);
|
||||
static void
|
||||
xmlSAX2ErrMemory(xmlParserCtxtPtr ctxt) {
|
||||
xmlCtxtErrMemory(ctxt);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -271,7 +256,7 @@ xmlSAX2InternalSubset(void *ctx, const xmlChar *name,
|
||||
ctxt->myDoc->intSubset =
|
||||
xmlCreateIntSubset(ctxt->myDoc, name, ExternalID, SystemID);
|
||||
if (ctxt->myDoc->intSubset == NULL)
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2InternalSubset");
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -316,7 +301,7 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
|
||||
}
|
||||
|
||||
if (xmlNewDtd(ctxt->myDoc, name, ExternalID, SystemID) == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
xmlFreeInputStream(input);
|
||||
return;
|
||||
}
|
||||
@ -336,7 +321,7 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
|
||||
ctxt->inputTab = (xmlParserInputPtr *)
|
||||
xmlMalloc(5 * sizeof(xmlParserInputPtr));
|
||||
if (ctxt->inputTab == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2ExternalSubset");
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
xmlFreeInputStream(input);
|
||||
ctxt->input = oldinput;
|
||||
ctxt->inputNr = oldinputNr;
|
||||
@ -431,7 +416,7 @@ xmlSAX2ResolveEntity(void *ctx, const xmlChar *publicId, const xmlChar *systemId
|
||||
base = ctxt->directory;
|
||||
|
||||
if (xmlBuildURISafe(systemId, (const xmlChar *) base, &URI) < 0)
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
|
||||
ret = xmlLoadExternalEntity((const char *) URI,
|
||||
(const char *) publicId, ctxt);
|
||||
@ -538,7 +523,7 @@ xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type,
|
||||
case XML_ERR_OK:
|
||||
break;
|
||||
case XML_ERR_NO_MEMORY:
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
return;
|
||||
case XML_WAR_ENTITY_REDEFINED:
|
||||
if (ctxt->pedantic) {
|
||||
@ -576,7 +561,7 @@ xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type,
|
||||
|
||||
if (base != NULL) {
|
||||
if (xmlBuildURISafe(systemId, (const xmlChar *) base, &URI) < 0)
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
else
|
||||
ent->URI = URI;
|
||||
}
|
||||
@ -623,7 +608,7 @@ xmlSAX2AttributeDecl(void *ctx, const xmlChar *elem, const xmlChar *fullname,
|
||||
/* TODO: optimize name/prefix allocation */
|
||||
name = xmlSplitQName(ctxt, fullname, &prefix);
|
||||
if (name == NULL)
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
ctxt->vctxt.valid = 1;
|
||||
if (ctxt->inSubset == 1)
|
||||
attr = xmlAddAttributeDecl(&ctxt->vctxt, ctxt->myDoc->intSubset, elem,
|
||||
@ -799,7 +784,7 @@ xmlSAX2StartDocument(void *ctx)
|
||||
if (ctxt->myDoc == NULL)
|
||||
ctxt->myDoc = htmlNewDocNoDtD(NULL, NULL);
|
||||
if (ctxt->myDoc == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartDocument");
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
ctxt->myDoc->properties = XML_DOC_HTML;
|
||||
@ -815,7 +800,7 @@ xmlSAX2StartDocument(void *ctx)
|
||||
doc->parseFlags = ctxt->options;
|
||||
doc->standalone = ctxt->standalone;
|
||||
} else {
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartDocument");
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
if ((ctxt->dictNames) && (doc != NULL)) {
|
||||
@ -823,7 +808,7 @@ xmlSAX2StartDocument(void *ctx)
|
||||
xmlDictReference(doc->dict);
|
||||
}
|
||||
if (xmlTreeEnsureXMLDecl(doc) == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -831,7 +816,7 @@ xmlSAX2StartDocument(void *ctx)
|
||||
(ctxt->input != NULL) && (ctxt->input->filename != NULL)) {
|
||||
ctxt->myDoc->URL = xmlPathToURI((const xmlChar *)ctxt->input->filename);
|
||||
if (ctxt->myDoc->URL == NULL)
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartDocument");
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -871,7 +856,7 @@ xmlSAX2EndDocument(void *ctx)
|
||||
if (encoding != NULL) {
|
||||
doc->encoding = xmlStrdup(encoding);
|
||||
if (doc->encoding == NULL)
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2EndDocument");
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -945,7 +930,7 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
|
||||
}
|
||||
}
|
||||
if (name == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement");
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
if (ns != NULL)
|
||||
xmlFree(ns);
|
||||
return;
|
||||
@ -956,7 +941,7 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
|
||||
(value == NULL) && (htmlIsBooleanAttr(fullname))) {
|
||||
nval = xmlStrdup(fullname);
|
||||
if (nval == NULL)
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
value = (const xmlChar *) nval;
|
||||
} else
|
||||
#endif
|
||||
@ -999,7 +984,7 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
|
||||
0,0,0);
|
||||
ctxt->depth--;
|
||||
if (val == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement");
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
if (name != NULL)
|
||||
xmlFree(name);
|
||||
if (nval != NULL)
|
||||
@ -1014,7 +999,7 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
|
||||
xmlURIPtr uri;
|
||||
|
||||
if (xmlParseURISafe((const char *)val, &uri) < 0)
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
if (uri == NULL) {
|
||||
xmlNsWarnMsg(ctxt, XML_WAR_NS_URI,
|
||||
"xmlns:%s: %s not a valid URI\n", name, value);
|
||||
@ -1031,7 +1016,7 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
|
||||
/* a default namespace definition */
|
||||
nsret = xmlNewNs(ctxt->node, val, NULL);
|
||||
if (nsret == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
}
|
||||
#ifdef LIBXML_VALID_ENABLED
|
||||
/*
|
||||
@ -1067,7 +1052,7 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
|
||||
0,0,0);
|
||||
ctxt->depth--;
|
||||
if (val == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement");
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
xmlFree(ns);
|
||||
if (name != NULL)
|
||||
xmlFree(name);
|
||||
@ -1087,7 +1072,7 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
|
||||
xmlURIPtr uri;
|
||||
|
||||
if (xmlParseURISafe((const char *)val, &uri) < 0)
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
if (uri == NULL) {
|
||||
xmlNsWarnMsg(ctxt, XML_WAR_NS_URI,
|
||||
"xmlns:%s: %s not a valid URI\n", name, value);
|
||||
@ -1105,7 +1090,7 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
|
||||
xmlFree(ns);
|
||||
|
||||
if (nsret == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
}
|
||||
#ifdef LIBXML_VALID_ENABLED
|
||||
/*
|
||||
@ -1163,7 +1148,7 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
|
||||
/* !!!!!! <a toto:arg="" xmlns:toto="http://toto.com"> */
|
||||
ret = xmlNewNsPropEatName(ctxt->node, namespace, name, NULL);
|
||||
if (ret == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -1173,7 +1158,7 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
|
||||
if ((value != NULL) && (value[0] != 0)) {
|
||||
ret->children = xmlStringGetNodeList(ctxt->myDoc, value);
|
||||
if (ret->children == NULL)
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
}
|
||||
tmp = ret->children;
|
||||
while (tmp != NULL) {
|
||||
@ -1185,7 +1170,7 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
|
||||
} else if (value != NULL) {
|
||||
ret->children = xmlNewDocText(ctxt->myDoc, value);
|
||||
if (ret->children == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
} else {
|
||||
ret->last = ret->children;
|
||||
ret->children->parent = (xmlNodePtr) ret;
|
||||
@ -1265,7 +1250,7 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
|
||||
int res = xmlIsID(ctxt->myDoc, ctxt->node, ret);
|
||||
|
||||
if (res < 0)
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlCtxtErrMemory(ctxt);
|
||||
else if (res > 0)
|
||||
xmlAddID(&ctxt->vctxt, ctxt->myDoc, content, ret);
|
||||
else if (xmlIsRef(ctxt->myDoc, ctxt->node, ret))
|
||||
@ -1328,7 +1313,7 @@ process_external_subset:
|
||||
fulln = xmlStrdup(attr->name);
|
||||
}
|
||||
if (fulln == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement");
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1394,7 +1379,7 @@ process_external_subset:
|
||||
|
||||
fulln = xmlBuildQName(attr->name, attr->prefix, fn, 50);
|
||||
if (fulln == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement");
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1479,7 +1464,7 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
|
||||
*/
|
||||
name = xmlSplitQName(ctxt, fullname, &prefix);
|
||||
if (name == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1492,7 +1477,7 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
|
||||
ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL, name, NULL);
|
||||
if (ret == NULL) {
|
||||
xmlFree(prefix);
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement");
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
ctxt->nodemem = -1;
|
||||
@ -1566,7 +1551,7 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
|
||||
prefix, NULL);
|
||||
ns = xmlNewNs(ret, NULL, prefix);
|
||||
if (ns == NULL)
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1687,7 +1672,7 @@ xmlSAX2TextNode(xmlParserCtxtPtr ctxt, const xmlChar *str, int len) {
|
||||
ret = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
|
||||
}
|
||||
if (ret == NULL) {
|
||||
xmlErrMemory(ctxt, "xmlSAX2Characters");
|
||||
xmlCtxtErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
memset(ret, 0, sizeof(xmlNode));
|
||||
@ -1709,7 +1694,7 @@ xmlSAX2TextNode(xmlParserCtxtPtr ctxt, const xmlChar *str, int len) {
|
||||
((cur == '<') && (str[len + 1] != '!')))) {
|
||||
intern = xmlDictLookup(ctxt->dict, str, len);
|
||||
if (intern == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2TextNode");
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
xmlFree(ret);
|
||||
return(NULL);
|
||||
}
|
||||
@ -1722,7 +1707,7 @@ xmlSAX2TextNode(xmlParserCtxtPtr ctxt, const xmlChar *str, int len) {
|
||||
}
|
||||
intern = xmlDictLookup(ctxt->dict, str, len);
|
||||
if (intern == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2TextNode");
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
xmlFree(ret);
|
||||
return(NULL);
|
||||
}
|
||||
@ -1735,7 +1720,7 @@ skip:
|
||||
if (intern == NULL) {
|
||||
ret->content = xmlStrndup(str, len);
|
||||
if (ret->content == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2TextNode");
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
xmlFree(ret);
|
||||
return(NULL);
|
||||
}
|
||||
@ -1825,7 +1810,7 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
|
||||
} else {
|
||||
ret = xmlMalloc(sizeof(*ret));
|
||||
if (ret == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
@ -1851,7 +1836,7 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
|
||||
} else {
|
||||
ret->name = xmlStrdup(localname);
|
||||
if (ret->name == NULL)
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
}
|
||||
|
||||
if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue))
|
||||
@ -1877,7 +1862,7 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
|
||||
ret->children = xmlStringLenGetNodeList(ctxt->myDoc, value,
|
||||
valueend - value);
|
||||
if (ret->children == NULL)
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
tmp = ret->children;
|
||||
while (tmp != NULL) {
|
||||
tmp->doc = ret->doc;
|
||||
@ -1920,7 +1905,7 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
|
||||
*/
|
||||
dup = xmlStrndup(value, valueend - value);
|
||||
if (dup == NULL)
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
|
||||
ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
|
||||
ctxt->myDoc, ctxt->node, ret, dup);
|
||||
@ -1966,7 +1951,7 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
|
||||
*/
|
||||
dup = xmlStrndup(value, valueend - value);
|
||||
if (dup == NULL)
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
|
||||
ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
|
||||
ctxt->myDoc, ctxt->node, ret, dup);
|
||||
@ -2003,7 +1988,7 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
|
||||
int res = xmlIsID(ctxt->myDoc, ctxt->node, ret);
|
||||
|
||||
if (res < 0)
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlCtxtErrMemory(ctxt);
|
||||
else if (res > 0)
|
||||
xmlAddID(&ctxt->vctxt, ctxt->myDoc, content, ret);
|
||||
else if (xmlIsRef(ctxt->myDoc, ctxt->node, ret))
|
||||
@ -2076,14 +2061,14 @@ xmlSAX2StartElementNs(void *ctx,
|
||||
|
||||
fullname = xmlDictQLookup(ctxt->dict, prefix, localname);
|
||||
if (fullname == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
localname = fullname;
|
||||
} else {
|
||||
lname = xmlBuildQName(localname, prefix, NULL, 0);
|
||||
if (lname == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2107,7 +2092,7 @@ xmlSAX2StartElementNs(void *ctx,
|
||||
else
|
||||
ret->name = lname;
|
||||
if (ret->name == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
xmlFree(ret);
|
||||
return;
|
||||
}
|
||||
@ -2124,7 +2109,7 @@ xmlSAX2StartElementNs(void *ctx,
|
||||
ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL,
|
||||
(xmlChar *) lname, NULL);
|
||||
if (ret == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2154,7 +2139,7 @@ xmlSAX2StartElementNs(void *ctx,
|
||||
if ((URI != NULL) && (prefix == pref))
|
||||
ret->ns = ns;
|
||||
} else {
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -2209,7 +2194,7 @@ xmlSAX2StartElementNs(void *ctx,
|
||||
ns = xmlNewNs(ret, NULL, prefix);
|
||||
if (ns == NULL) {
|
||||
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
if (prefix != NULL)
|
||||
@ -2242,7 +2227,7 @@ xmlSAX2StartElementNs(void *ctx,
|
||||
fullname = xmlDictQLookup(ctxt->dict, attributes[j+1],
|
||||
attributes[j]);
|
||||
if (fullname == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
attr = xmlSAX2AttributeNs(ctxt, fullname, NULL,
|
||||
@ -2253,7 +2238,7 @@ xmlSAX2StartElementNs(void *ctx,
|
||||
lname = xmlBuildQName(attributes[j], attributes[j+1],
|
||||
NULL, 0);
|
||||
if (lname == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
attr = xmlSAX2AttributeNs(ctxt, lname, NULL,
|
||||
@ -2351,7 +2336,7 @@ xmlSAX2Reference(void *ctx, const xmlChar *name)
|
||||
if (ctx == NULL) return;
|
||||
ret = xmlNewReference(ctxt->myDoc, name);
|
||||
if (ret == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
if (xmlAddChild(ctxt->node, ret) == NULL) {
|
||||
@ -2403,7 +2388,7 @@ xmlSAX2Text(xmlParserCtxtPtr ctxt, const xmlChar *ch, int len,
|
||||
ctxt->nodelen = len;
|
||||
ctxt->nodemem = len + 1;
|
||||
} else {
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters");
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@ -2427,16 +2412,16 @@ xmlSAX2Text(xmlParserCtxtPtr ctxt, const xmlChar *ch, int len,
|
||||
lastChild->content = xmlStrdup(lastChild->content);
|
||||
}
|
||||
if (lastChild->content == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters: xmlStrdup returned NULL");
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
if (ctxt->nodelen > INT_MAX - len) {
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters overflow prevented");
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
if ((ctxt->nodelen + len > XML_MAX_TEXT_LENGTH) &&
|
||||
((ctxt->options & XML_PARSE_HUGE) == 0)) {
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters: huge text node");
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
if (ctxt->nodelen + len >= ctxt->nodemem) {
|
||||
@ -2449,7 +2434,7 @@ xmlSAX2Text(xmlParserCtxtPtr ctxt, const xmlChar *ch, int len,
|
||||
size = size > INT_MAX / 2 ? INT_MAX : size * 2;
|
||||
newbuf = (xmlChar *) xmlRealloc(lastChild->content,size);
|
||||
if (newbuf == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters");
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
ctxt->nodemem = size;
|
||||
@ -2460,7 +2445,7 @@ xmlSAX2Text(xmlParserCtxtPtr ctxt, const xmlChar *ch, int len,
|
||||
lastChild->content[ctxt->nodelen] = 0;
|
||||
} else if (coalesceText) {
|
||||
if (xmlTextConcat(lastChild, ch, len)) {
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters");
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
}
|
||||
if (ctxt->node->children != NULL) {
|
||||
ctxt->nodelen = xmlStrlen(lastChild->content);
|
||||
@ -2475,7 +2460,7 @@ xmlSAX2Text(xmlParserCtxtPtr ctxt, const xmlChar *ch, int len,
|
||||
} else
|
||||
lastChild = xmlNewCDataBlock(ctxt->myDoc, ch, len);
|
||||
if (lastChild == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
} else {
|
||||
xmlAddChild(ctxt->node, lastChild);
|
||||
if (ctxt->node->children != NULL) {
|
||||
@ -2549,7 +2534,7 @@ xmlSAX2ProcessingInstruction(void *ctx, const xmlChar *target,
|
||||
|
||||
ret = xmlNewDocPI(ctxt->myDoc, target, data);
|
||||
if (ret == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2597,7 +2582,7 @@ xmlSAX2Comment(void *ctx, const xmlChar *value)
|
||||
parent = ctxt->node;
|
||||
ret = xmlNewDocComment(ctxt->myDoc, value);
|
||||
if (ret == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
xmlSAX2ErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
if (ctxt->linenumbers) {
|
||||
|
@ -378,14 +378,14 @@ xmlFuzzEntityLoader(const char *URL, const char *ID ATTRIBUTE_UNUSED,
|
||||
return(NULL);
|
||||
input->filename = (char *) xmlCharStrdup(URL);
|
||||
if (input->filename == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlCtxtErrMemory(ctxt);
|
||||
xmlFreeInputStream(input);
|
||||
return(NULL);
|
||||
}
|
||||
input->buf = xmlParserInputBufferCreateMem(entity->data, entity->size,
|
||||
XML_CHAR_ENCODING_NONE);
|
||||
if (input->buf == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlCtxtErrMemory(ctxt);
|
||||
xmlFreeInputStream(input);
|
||||
return(NULL);
|
||||
}
|
||||
|
18
globals.c
18
globals.c
@ -272,8 +272,7 @@ const int oldXMLWDcompatibility = 0; /* DEPRECATED */
|
||||
* while handling entities.
|
||||
* Disabled by default
|
||||
*/
|
||||
int xmlParserDebugEntities = 0;
|
||||
static int xmlParserDebugEntitiesThrDef = 0;
|
||||
const int xmlParserDebugEntities = 0;
|
||||
/**
|
||||
* xmlDoValidityCheckingDefaultValue:
|
||||
*
|
||||
@ -782,7 +781,6 @@ xmlInitGlobalState(xmlGlobalStatePtr gs) {
|
||||
gs->gs_xmlKeepBlanksDefaultValue = xmlKeepBlanksDefaultValueThrDef;
|
||||
gs->gs_xmlLineNumbersDefaultValue = xmlLineNumbersDefaultValueThrDef;
|
||||
gs->gs_xmlLoadExtDtdDefaultValue = xmlLoadExtDtdDefaultValueThrDef;
|
||||
gs->gs_xmlParserDebugEntities = xmlParserDebugEntitiesThrDef;
|
||||
gs->gs_xmlPedanticParserDefaultValue = xmlPedanticParserDefaultValueThrDef;
|
||||
gs->gs_xmlSubstituteEntitiesDefaultValue =
|
||||
xmlSubstituteEntitiesDefaultValueThrDef;
|
||||
@ -907,6 +905,11 @@ __oldXMLWDcompatibility(void) {
|
||||
return &oldXMLWDcompatibility;
|
||||
}
|
||||
|
||||
const int *
|
||||
__xmlParserDebugEntities(void) {
|
||||
return &xmlParserDebugEntities;
|
||||
}
|
||||
|
||||
const xmlSAXLocator *
|
||||
__xmlDefaultSAXLocator(void) {
|
||||
return &xmlDefaultSAXLocator;
|
||||
@ -1124,13 +1127,8 @@ int xmlThrDefLoadExtDtdDefaultValue(int v) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xmlThrDefParserDebugEntities(int v) {
|
||||
int ret;
|
||||
xmlMutexLock(&xmlThrDefMutex);
|
||||
ret = xmlParserDebugEntitiesThrDef;
|
||||
xmlParserDebugEntitiesThrDef = v;
|
||||
xmlMutexUnlock(&xmlThrDefMutex);
|
||||
return ret;
|
||||
int xmlThrDefParserDebugEntities(int v ATTRIBUTE_UNUSED) {
|
||||
return(xmlParserDebugEntities);
|
||||
}
|
||||
|
||||
int xmlThrDefPedanticParserDefaultValue(int v) {
|
||||
|
@ -325,6 +325,9 @@ struct _xmlParserCtxt {
|
||||
xmlParserNsData *nsdb; /* namespace database */
|
||||
unsigned attrHashMax; /* allocated size */
|
||||
xmlAttrHashBucket *attrHash; /* atttribute hash table */
|
||||
|
||||
xmlStructuredErrorFunc errorHandler;
|
||||
void *errorCtxt;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -844,6 +847,8 @@ XMLPUBVAR const char *const xmlParserVersion;
|
||||
XML_DEPRECATED
|
||||
XMLPUBVAR const int oldXMLWDcompatibility;
|
||||
XML_DEPRECATED
|
||||
XMLPUBVAR const int xmlParserDebugEntities;
|
||||
XML_DEPRECATED
|
||||
XMLPUBVAR const xmlSAXLocator xmlDefaultSAXLocator;
|
||||
#ifdef LIBXML_SAX1_ENABLED
|
||||
XML_DEPRECATED
|
||||
@ -856,6 +861,8 @@ XMLPUBFUN const char *const *__xmlParserVersion(void);
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN const int *__oldXMLWDcompatibility(void);
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN const int *__xmlParserDebugEntities(void);
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN const xmlSAXLocator *__xmlDefaultSAXLocator(void);
|
||||
#ifdef LIBXML_SAX1_ENABLED
|
||||
XML_DEPRECATED
|
||||
@ -870,7 +877,6 @@ XMLPUBFUN const xmlSAXHandlerV1 *__xmlDefaultSAXHandler(void);
|
||||
XML_OP(xmlKeepBlanksDefaultValue, int, XML_DEPRECATED) \
|
||||
XML_OP(xmlLineNumbersDefaultValue, int, XML_DEPRECATED) \
|
||||
XML_OP(xmlLoadExtDtdDefaultValue, int, XML_DEPRECATED) \
|
||||
XML_OP(xmlParserDebugEntities, int, XML_DEPRECATED) \
|
||||
XML_OP(xmlPedanticParserDefaultValue, int, XML_DEPRECATED) \
|
||||
XML_OP(xmlSubstituteEntitiesDefaultValue, int, XML_DEPRECATED)
|
||||
|
||||
@ -903,7 +909,6 @@ XML_GLOBALS_PARSER
|
||||
#define xmlLineNumbersDefaultValue \
|
||||
XML_GLOBAL_MACRO(xmlLineNumbersDefaultValue)
|
||||
#define xmlLoadExtDtdDefaultValue XML_GLOBAL_MACRO(xmlLoadExtDtdDefaultValue)
|
||||
#define xmlParserDebugEntities XML_GLOBAL_MACRO(xmlParserDebugEntities)
|
||||
#define xmlPedanticParserDefaultValue \
|
||||
XML_GLOBAL_MACRO(xmlPedanticParserDefaultValue)
|
||||
#define xmlSubstituteEntitiesDefaultValue \
|
||||
@ -1270,6 +1275,10 @@ XMLPUBFUN int
|
||||
XMLPUBFUN int
|
||||
xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,
|
||||
int options);
|
||||
XMLPUBFUN void
|
||||
xmlCtxtSetErrorHandler (xmlParserCtxtPtr ctxt,
|
||||
xmlStructuredErrorFunc handler,
|
||||
void *data);
|
||||
XMLPUBFUN void
|
||||
xmlCtxtSetMaxAmplification(xmlParserCtxtPtr ctxt,
|
||||
unsigned maxAmpl);
|
||||
|
@ -314,8 +314,7 @@ XMLPUBFUN xmlParserCtxtPtr
|
||||
const xmlChar *ID,
|
||||
const xmlChar *base);
|
||||
XMLPUBFUN void
|
||||
xmlErrMemory (xmlParserCtxtPtr ctxt,
|
||||
const char *extra);
|
||||
xmlCtxtErrMemory (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN int
|
||||
xmlSwitchEncoding (xmlParserCtxtPtr ctxt,
|
||||
xmlCharEncoding enc);
|
||||
|
@ -28,6 +28,8 @@
|
||||
|
||||
#define PARSER_STOPPED(ctxt) ((ctxt)->disableSAX > 1)
|
||||
|
||||
XML_HIDDEN void
|
||||
xmlErrMemory(xmlParserCtxtPtr ctxt);
|
||||
XML_HIDDEN void
|
||||
xmlVErrParser(xmlParserCtxtPtr ctxt, xmlNodePtr node,
|
||||
int domain, int code, xmlErrorLevel level,
|
||||
|
247
parser.c
247
parser.c
@ -229,6 +229,11 @@ xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity);
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
void
|
||||
xmlErrMemory(xmlParserCtxtPtr ctxt) {
|
||||
xmlCtxtErrMemory(ctxt);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlErrAttributeDup:
|
||||
* @ctxt: an XML parser context
|
||||
@ -761,7 +766,7 @@ xmlDetectSAX2(xmlParserCtxtPtr ctxt) {
|
||||
ctxt->str_xml_ns = xmlDictLookup(ctxt->dict, XML_XML_NAMESPACE, 36);
|
||||
if ((ctxt->str_xml==NULL) || (ctxt->str_xmlns==NULL) ||
|
||||
(ctxt->str_xml_ns == NULL)) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -871,7 +876,7 @@ xmlAttrNormalizeSpace2(xmlParserCtxtPtr ctxt, xmlChar *src, int *len)
|
||||
|
||||
ret = xmlStrndup(src + remove_head, i - remove_head + 1);
|
||||
if (ret == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
xmlAttrNormalizeSpace(ret, ret);
|
||||
@ -1002,7 +1007,7 @@ xmlAddDefAttrs(xmlParserCtxtPtr ctxt,
|
||||
return;
|
||||
|
||||
mem_error:
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1033,7 +1038,7 @@ xmlAddSpecialAttr(xmlParserCtxtPtr ctxt,
|
||||
return;
|
||||
|
||||
mem_error:
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1527,7 +1532,7 @@ xmlParserNsGrow(xmlParserCtxtPtr ctxt) {
|
||||
return(0);
|
||||
|
||||
error:
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
@ -1556,7 +1561,7 @@ xmlParserNsPush(xmlParserCtxtPtr ctxt, const xmlHashedString *prefix,
|
||||
return(0);
|
||||
|
||||
if ((ctxt->nsNr >= ctxt->nsMax) && (xmlParserNsGrow(ctxt) < 0)) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
@ -1622,13 +1627,13 @@ xmlParserNsPush(xmlParserCtxtPtr ctxt, const xmlHashedString *prefix,
|
||||
unsigned newSize, i, index;
|
||||
|
||||
if (ctxt->nsdb->hashSize > UINT_MAX / 2) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(-1);
|
||||
}
|
||||
newSize = ctxt->nsdb->hashSize ? ctxt->nsdb->hashSize * 2 : 16;
|
||||
newHash = xmlMalloc(newSize * sizeof(newHash[0]));
|
||||
if (newHash == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(-1);
|
||||
}
|
||||
memset(newHash, 0, newSize * sizeof(newHash[0]));
|
||||
@ -1756,7 +1761,7 @@ xmlCtxtGrowAttrs(xmlParserCtxtPtr ctxt, int nr) {
|
||||
}
|
||||
return(ctxt->maxatts);
|
||||
mem_error:
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
@ -1781,7 +1786,7 @@ inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
|
||||
tmp = (xmlParserInputPtr *) xmlRealloc(ctxt->inputTab,
|
||||
newSize * sizeof(*tmp));
|
||||
if (tmp == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return (-1);
|
||||
}
|
||||
ctxt->inputTab = tmp;
|
||||
@ -1839,7 +1844,7 @@ nodePush(xmlParserCtxtPtr ctxt, xmlNodePtr value)
|
||||
ctxt->nodeMax * 2 *
|
||||
sizeof(ctxt->nodeTab[0]));
|
||||
if (tmp == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return (-1);
|
||||
}
|
||||
ctxt->nodeTab = tmp;
|
||||
@ -1940,7 +1945,7 @@ nameNsPush(xmlParserCtxtPtr ctxt, const xmlChar * value,
|
||||
tag->nsNr = nsNr;
|
||||
return (ctxt->nameNr++);
|
||||
mem_error:
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return (-1);
|
||||
}
|
||||
#ifdef LIBXML_PUSH_ENABLED
|
||||
@ -2001,7 +2006,7 @@ namePush(xmlParserCtxtPtr ctxt, const xmlChar * value)
|
||||
ctxt->name = value;
|
||||
return (ctxt->nameNr++);
|
||||
mem_error:
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
@ -2040,7 +2045,7 @@ static int spacePush(xmlParserCtxtPtr ctxt, int val) {
|
||||
tmp = (int *) xmlRealloc(ctxt->spaceTab,
|
||||
ctxt->spaceMax * sizeof(ctxt->spaceTab[0]));
|
||||
if (tmp == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
ctxt->spaceMax /=2;
|
||||
return(-1);
|
||||
}
|
||||
@ -2296,9 +2301,6 @@ xmlPopInput(xmlParserCtxtPtr ctxt) {
|
||||
xmlParserInputPtr input;
|
||||
|
||||
if ((ctxt == NULL) || (ctxt->inputNr <= 1)) return(0);
|
||||
if (xmlParserDebugEntities)
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Popping input %d\n", ctxt->inputNr);
|
||||
input = inputPop(ctxt);
|
||||
if (input->entity != NULL)
|
||||
input->entity->flags &= ~XML_ENT_EXPANDING;
|
||||
@ -2322,14 +2324,6 @@ xmlPushInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr input) {
|
||||
int ret;
|
||||
if (input == NULL) return(-1);
|
||||
|
||||
if (xmlParserDebugEntities) {
|
||||
if ((ctxt->input != NULL) && (ctxt->input->filename))
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"%s(%d): ", ctxt->input->filename,
|
||||
ctxt->input->line);
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Pushing input %d : %.30s\n", ctxt->inputNr+1, input->cur);
|
||||
}
|
||||
if (((ctxt->inputNr > 40) && ((ctxt->options & XML_PARSE_HUGE) == 0)) ||
|
||||
(ctxt->inputNr > 100)) {
|
||||
xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
|
||||
@ -2718,10 +2712,6 @@ xmlStringDecodeEntitiesInt(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
|
||||
growBuffer(buffer, XML_PARSER_BUFFER_SIZE);
|
||||
}
|
||||
} else if ((c == '&') && (what & XML_SUBSTITUTE_REF)) {
|
||||
if (xmlParserDebugEntities)
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"String decoding Entity Reference: %.30s\n",
|
||||
str);
|
||||
ent = xmlParseStringEntityRef(ctxt, &str);
|
||||
if ((ent != NULL) &&
|
||||
(ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) {
|
||||
@ -2780,9 +2770,6 @@ xmlStringDecodeEntitiesInt(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
|
||||
buffer[nbchars++] = ';';
|
||||
}
|
||||
} else if (c == '%' && (what & XML_SUBSTITUTE_PEREF)) {
|
||||
if (xmlParserDebugEntities)
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"String decoding PE Reference: %.30s\n", str);
|
||||
ent = xmlParseStringPEReference(ctxt, &str);
|
||||
if (ent != NULL) {
|
||||
if (ent->content == NULL) {
|
||||
@ -2852,7 +2839,7 @@ xmlStringDecodeEntitiesInt(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
|
||||
return(buffer);
|
||||
|
||||
mem_error:
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
int_error:
|
||||
if (rep != NULL)
|
||||
xmlFree(rep);
|
||||
@ -3076,7 +3063,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefixOut) {
|
||||
|
||||
buffer = (xmlChar *) xmlMallocAtomic(max);
|
||||
if (buffer == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
memcpy(buffer, buf, len);
|
||||
@ -3088,7 +3075,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefixOut) {
|
||||
tmp = (xmlChar *) xmlRealloc(buffer, max);
|
||||
if (tmp == NULL) {
|
||||
xmlFree(buffer);
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
buffer = tmp;
|
||||
@ -3108,7 +3095,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefixOut) {
|
||||
if (buffer == NULL) {
|
||||
ret = xmlStrndup(buf, len);
|
||||
if (ret == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
} else {
|
||||
@ -3163,7 +3150,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefixOut) {
|
||||
|
||||
buffer = (xmlChar *) xmlMallocAtomic(max);
|
||||
if (buffer == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
xmlFree(prefix);
|
||||
return(NULL);
|
||||
}
|
||||
@ -3175,7 +3162,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefixOut) {
|
||||
max *= 2;
|
||||
tmp = (xmlChar *) xmlRealloc(buffer, max);
|
||||
if (tmp == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
xmlFree(prefix);
|
||||
xmlFree(buffer);
|
||||
return(NULL);
|
||||
@ -3406,7 +3393,7 @@ xmlParseNameComplex(xmlParserCtxtPtr ctxt) {
|
||||
else
|
||||
ret = xmlDictLookup(ctxt->dict, ctxt->input->cur - len, len);
|
||||
if (ret == NULL)
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@ -3463,7 +3450,7 @@ xmlParseName(xmlParserCtxtPtr ctxt) {
|
||||
ctxt->input->cur = in;
|
||||
ctxt->input->col += count;
|
||||
if (ret == NULL)
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(ret);
|
||||
}
|
||||
}
|
||||
@ -3507,7 +3494,7 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) {
|
||||
}
|
||||
ret = xmlDictLookupHashed(ctxt->dict, (BASE_PTR + startPosition), len);
|
||||
if (ret.name == NULL)
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@ -3564,7 +3551,7 @@ xmlParseNCName(xmlParserCtxtPtr ctxt) {
|
||||
ctxt->input->cur = in;
|
||||
ctxt->input->col += count;
|
||||
if (ret.name == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
@ -3663,7 +3650,7 @@ xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar** str) {
|
||||
|
||||
buffer = (xmlChar *) xmlMallocAtomic(max);
|
||||
if (buffer == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
memcpy(buffer, buf, len);
|
||||
@ -3674,7 +3661,7 @@ xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar** str) {
|
||||
max *= 2;
|
||||
tmp = (xmlChar *) xmlRealloc(buffer, max);
|
||||
if (tmp == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
xmlFree(buffer);
|
||||
return(NULL);
|
||||
}
|
||||
@ -3701,7 +3688,7 @@ xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar** str) {
|
||||
*str = cur;
|
||||
ret = xmlStrndup(buf, len);
|
||||
if (ret == NULL)
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@ -3746,7 +3733,7 @@ xmlParseNmtoken(xmlParserCtxtPtr ctxt) {
|
||||
|
||||
buffer = (xmlChar *) xmlMallocAtomic(max);
|
||||
if (buffer == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
memcpy(buffer, buf, len);
|
||||
@ -3757,7 +3744,7 @@ xmlParseNmtoken(xmlParserCtxtPtr ctxt) {
|
||||
max *= 2;
|
||||
tmp = (xmlChar *) xmlRealloc(buffer, max);
|
||||
if (tmp == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
xmlFree(buffer);
|
||||
return(NULL);
|
||||
}
|
||||
@ -3784,7 +3771,7 @@ xmlParseNmtoken(xmlParserCtxtPtr ctxt) {
|
||||
}
|
||||
ret = xmlStrndup(buf, len);
|
||||
if (ret == NULL)
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@ -3825,7 +3812,7 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) {
|
||||
}
|
||||
buf = (xmlChar *) xmlMallocAtomic(size);
|
||||
if (buf == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
@ -3855,7 +3842,7 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) {
|
||||
size *= 2;
|
||||
tmp = (xmlChar *) xmlRealloc(buf, size);
|
||||
if (tmp == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
goto error;
|
||||
}
|
||||
buf = tmp;
|
||||
@ -4188,7 +4175,7 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
|
||||
return(buf);
|
||||
|
||||
mem_error:
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
error:
|
||||
if (buf != NULL)
|
||||
xmlFree(buf);
|
||||
@ -4277,7 +4264,7 @@ xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) {
|
||||
|
||||
buf = (xmlChar *) xmlMallocAtomic(size);
|
||||
if (buf == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
ctxt->instate = XML_PARSER_SYSTEM_LITERAL;
|
||||
@ -4290,7 +4277,7 @@ xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) {
|
||||
tmp = (xmlChar *) xmlRealloc(buf, size);
|
||||
if (tmp == NULL) {
|
||||
xmlFree(buf);
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
buf = tmp;
|
||||
@ -4352,7 +4339,7 @@ xmlParsePubidLiteral(xmlParserCtxtPtr ctxt) {
|
||||
}
|
||||
buf = (xmlChar *) xmlMallocAtomic(size);
|
||||
if (buf == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
ctxt->instate = XML_PARSER_PUBLIC_LITERAL;
|
||||
@ -4365,7 +4352,7 @@ xmlParsePubidLiteral(xmlParserCtxtPtr ctxt) {
|
||||
size *= 2;
|
||||
tmp = (xmlChar *) xmlRealloc(buf, size);
|
||||
if (tmp == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
xmlFree(buf);
|
||||
return(NULL);
|
||||
}
|
||||
@ -4798,7 +4785,7 @@ xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf,
|
||||
size = XML_PARSER_BUFFER_SIZE;
|
||||
buf = (xmlChar *) xmlMallocAtomic(size);
|
||||
if (buf == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -4841,7 +4828,7 @@ xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf,
|
||||
new_buf = (xmlChar *) xmlRealloc(buf, new_size);
|
||||
if (new_buf == NULL) {
|
||||
xmlFree (buf);
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
buf = new_buf;
|
||||
@ -4973,7 +4960,7 @@ get_more:
|
||||
size = XML_PARSER_BUFFER_SIZE + nbchar;
|
||||
buf = (xmlChar *) xmlMallocAtomic(size);
|
||||
if (buf == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
len = 0;
|
||||
@ -4983,7 +4970,7 @@ get_more:
|
||||
new_buf = (xmlChar *) xmlRealloc(buf, size);
|
||||
if (new_buf == NULL) {
|
||||
xmlFree (buf);
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
buf = new_buf;
|
||||
@ -5229,7 +5216,7 @@ xmlParsePI(xmlParserCtxtPtr ctxt) {
|
||||
}
|
||||
buf = (xmlChar *) xmlMallocAtomic(size);
|
||||
if (buf == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
if (SKIP_BLANKS == 0) {
|
||||
@ -5244,7 +5231,7 @@ xmlParsePI(xmlParserCtxtPtr ctxt) {
|
||||
size_t new_size = size * 2;
|
||||
tmp = (xmlChar *) xmlRealloc(buf, new_size);
|
||||
if (tmp == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
xmlFree(buf);
|
||||
return;
|
||||
}
|
||||
@ -5473,7 +5460,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
|
||||
xmlURIPtr uri;
|
||||
|
||||
if (xmlParseURISafe((const char *) URI, &uri) < 0) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
} else if (uri == NULL) {
|
||||
/*
|
||||
* This really ought to be a well formedness error
|
||||
@ -5515,7 +5502,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
|
||||
if (ctxt->myDoc == NULL) {
|
||||
ctxt->myDoc = xmlNewDoc(SAX_COMPAT_MODE);
|
||||
if (ctxt->myDoc == NULL) {
|
||||
xmlErrMemory(ctxt, "New Doc failed");
|
||||
xmlErrMemory(ctxt);
|
||||
goto done;
|
||||
}
|
||||
ctxt->myDoc->properties = XML_DOC_INTERNAL;
|
||||
@ -5524,7 +5511,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
|
||||
ctxt->myDoc->intSubset = xmlNewDtd(ctxt->myDoc,
|
||||
BAD_CAST "fake", NULL, NULL);
|
||||
if (ctxt->myDoc->intSubset == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
@ -5541,7 +5528,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
|
||||
xmlURIPtr uri;
|
||||
|
||||
if (xmlParseURISafe((const char *) URI, &uri) < 0) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
} else if (uri == NULL) {
|
||||
/*
|
||||
* This really ought to be a well formedness error
|
||||
@ -5590,7 +5577,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
|
||||
if (ctxt->myDoc == NULL) {
|
||||
ctxt->myDoc = xmlNewDoc(SAX_COMPAT_MODE);
|
||||
if (ctxt->myDoc == NULL) {
|
||||
xmlErrMemory(ctxt, "New Doc failed");
|
||||
xmlErrMemory(ctxt);
|
||||
goto done;
|
||||
}
|
||||
ctxt->myDoc->properties = XML_DOC_INTERNAL;
|
||||
@ -5600,7 +5587,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
|
||||
ctxt->myDoc->intSubset = xmlNewDtd(ctxt->myDoc,
|
||||
BAD_CAST "fake", NULL, NULL);
|
||||
if (ctxt->myDoc->intSubset == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
@ -5773,7 +5760,7 @@ xmlParseNotationType(xmlParserCtxtPtr ctxt) {
|
||||
if (tmp == NULL) {
|
||||
cur = xmlCreateEnumeration(name);
|
||||
if (cur == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
xmlFreeEnumeration(ret);
|
||||
return(NULL);
|
||||
}
|
||||
@ -5845,7 +5832,7 @@ xmlParseEnumerationType(xmlParserCtxtPtr ctxt) {
|
||||
if (!xmlDictOwns(ctxt->dict, name))
|
||||
xmlFree(name);
|
||||
if (cur == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
xmlFreeEnumeration(ret);
|
||||
return(NULL);
|
||||
}
|
||||
@ -6212,7 +6199,7 @@ xmlParseElementMixedContentDecl(xmlParserCtxtPtr ctxt, int inputchk) {
|
||||
return(ret);
|
||||
|
||||
mem_error:
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
xmlFreeDocElementContent(ctxt->myDoc, ret);
|
||||
return(NULL);
|
||||
}
|
||||
@ -6285,7 +6272,7 @@ xmlParseElementChildrenContentDeclPriv(xmlParserCtxtPtr ctxt, int inputchk,
|
||||
}
|
||||
cur = ret = xmlNewDocElementContent(ctxt->myDoc, elem, XML_ELEMENT_CONTENT_ELEMENT);
|
||||
if (cur == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
GROW;
|
||||
@ -6328,7 +6315,7 @@ xmlParseElementChildrenContentDeclPriv(xmlParserCtxtPtr ctxt, int inputchk,
|
||||
|
||||
op = xmlNewDocElementContent(ctxt->myDoc, NULL, XML_ELEMENT_CONTENT_SEQ);
|
||||
if (op == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
if ((last != NULL) && (last != ret))
|
||||
xmlFreeDocElementContent(ctxt->myDoc, last);
|
||||
xmlFreeDocElementContent(ctxt->myDoc, ret);
|
||||
@ -6369,7 +6356,7 @@ xmlParseElementChildrenContentDeclPriv(xmlParserCtxtPtr ctxt, int inputchk,
|
||||
|
||||
op = xmlNewDocElementContent(ctxt->myDoc, NULL, XML_ELEMENT_CONTENT_OR);
|
||||
if (op == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
if ((last != NULL) && (last != ret))
|
||||
xmlFreeDocElementContent(ctxt->myDoc, last);
|
||||
if (ret != NULL)
|
||||
@ -6425,7 +6412,7 @@ xmlParseElementChildrenContentDeclPriv(xmlParserCtxtPtr ctxt, int inputchk,
|
||||
}
|
||||
last = xmlNewDocElementContent(ctxt->myDoc, elem, XML_ELEMENT_CONTENT_ELEMENT);
|
||||
if (last == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
if (ret != NULL)
|
||||
xmlFreeDocElementContent(ctxt->myDoc, ret);
|
||||
return(NULL);
|
||||
@ -6769,7 +6756,7 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
|
||||
tmp = (int *) xmlRealloc(inputIds,
|
||||
inputIdsSize * sizeof(int));
|
||||
if (tmp == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
goto error;
|
||||
}
|
||||
inputIds = tmp;
|
||||
@ -6803,7 +6790,7 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
|
||||
ignoreDepth++;
|
||||
/* Check for integer overflow */
|
||||
if (ignoreDepth == 0) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
goto error;
|
||||
}
|
||||
} else if ((RAW == ']') && (NXT(1) == ']') &&
|
||||
@ -6958,7 +6945,7 @@ xmlParseTextDecl(xmlParserCtxtPtr ctxt) {
|
||||
if (version == NULL) {
|
||||
version = xmlCharStrdup(XML_DEFAULT_VERSION);
|
||||
if (version == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@ -7034,14 +7021,14 @@ xmlParseExternalSubset(xmlParserCtxtPtr ctxt, const xmlChar *ExternalID,
|
||||
if (ctxt->myDoc == NULL) {
|
||||
ctxt->myDoc = xmlNewDoc(BAD_CAST "1.0");
|
||||
if (ctxt->myDoc == NULL) {
|
||||
xmlErrMemory(ctxt, "New Doc failed");
|
||||
xmlErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
ctxt->myDoc->properties = XML_DOC_INTERNAL;
|
||||
}
|
||||
if ((ctxt->myDoc != NULL) && (ctxt->myDoc->intSubset == NULL) &&
|
||||
(xmlCreateIntSubset(ctxt->myDoc, NULL, ExternalID, SystemID) == NULL)) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
}
|
||||
|
||||
ctxt->instate = XML_PARSER_DTD;
|
||||
@ -7416,7 +7403,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
|
||||
while (cur != NULL) {
|
||||
nw = xmlDocCopyNode(cur, ctxt->myDoc, 1);
|
||||
if (nw == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
} else {
|
||||
if (nw->_private == NULL)
|
||||
nw->_private = cur->_private;
|
||||
@ -7425,7 +7412,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
|
||||
}
|
||||
nw = xmlAddChild(ctxt->node, nw);
|
||||
if (nw == NULL)
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
}
|
||||
if (cur == ent->last) {
|
||||
/*
|
||||
@ -7466,7 +7453,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
|
||||
cur->parent = NULL;
|
||||
nw = xmlDocCopyNode(cur, ctxt->myDoc, 1);
|
||||
if (nw == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
} else {
|
||||
if (nw->_private == NULL)
|
||||
nw->_private = cur->_private;
|
||||
@ -7474,10 +7461,10 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
|
||||
firstChild = cur;
|
||||
}
|
||||
if (xmlAddChild((xmlNodePtr) ent, nw) == NULL)
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
}
|
||||
if (xmlAddChild(ctxt->node, cur) == NULL)
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
if (cur == last)
|
||||
break;
|
||||
cur = next;
|
||||
@ -7934,9 +7921,6 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt)
|
||||
xmlFatalErrMsg(ctxt, XML_ERR_PEREF_NO_NAME, "PEReference: no name\n");
|
||||
return;
|
||||
}
|
||||
if (xmlParserDebugEntities)
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"PEReference: %s\n", name);
|
||||
if (RAW != ';') {
|
||||
xmlFatalErr(ctxt, XML_ERR_PEREF_SEMICOL_MISSING, NULL);
|
||||
return;
|
||||
@ -8076,10 +8060,6 @@ xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if (xmlParserDebugEntities)
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Reading %s entity content input\n", entity->name);
|
||||
|
||||
input = xmlLoadExternalEntity((char *) entity->URI,
|
||||
(char *) entity->ExternalID, ctxt);
|
||||
if (input == NULL) {
|
||||
@ -8102,7 +8082,7 @@ xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
|
||||
ctxt->progressive = 0;
|
||||
ctxt->inputTab = xmlMalloc(sizeof(xmlParserInputPtr));
|
||||
if (ctxt->inputTab == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
xmlFreeInputStream(input);
|
||||
goto error;
|
||||
}
|
||||
@ -8146,7 +8126,7 @@ xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
|
||||
content = xmlBufDetach(input->buf->buffer);
|
||||
|
||||
if (length > INT_MAX) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -8622,7 +8602,7 @@ xmlParseStartTag(xmlParserCtxtPtr ctxt) {
|
||||
atts = (const xmlChar **)
|
||||
xmlMalloc(maxatts * sizeof(xmlChar *));
|
||||
if (atts == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
if (attvalue != NULL)
|
||||
xmlFree(attvalue);
|
||||
goto failed;
|
||||
@ -8636,7 +8616,7 @@ xmlParseStartTag(xmlParserCtxtPtr ctxt) {
|
||||
n = (const xmlChar **) xmlRealloc((void *) atts,
|
||||
maxatts * sizeof(const xmlChar *));
|
||||
if (n == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
if (attvalue != NULL)
|
||||
xmlFree(attvalue);
|
||||
goto failed;
|
||||
@ -8825,7 +8805,7 @@ xmlParseQNameHashed(xmlParserCtxtPtr ctxt, xmlHashedString *prefix) {
|
||||
l = xmlDictLookupHashed(ctxt->dict, BASE_PTR + start,
|
||||
CUR_PTR - (BASE_PTR + start));
|
||||
if (l.name == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(l);
|
||||
}
|
||||
xmlNsErr(ctxt, XML_NS_ERR_QNAME,
|
||||
@ -9100,7 +9080,7 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
|
||||
if (alloc) *alloc = 1;
|
||||
ret = xmlStrndup(start, last - start);
|
||||
if (ret == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
@ -9244,7 +9224,7 @@ xmlParseAttribute2(xmlParserCtxtPtr ctxt,
|
||||
return (hname);
|
||||
|
||||
mem_error:
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
error:
|
||||
if ((val != NULL) && (*alloc != 0))
|
||||
xmlFree(val);
|
||||
@ -9361,7 +9341,7 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,
|
||||
attval = 0;
|
||||
|
||||
if (xmlParserNsStartElement(ctxt->nsdb) < 0) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
@ -9432,12 +9412,12 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,
|
||||
huri = xmlDictLookupHashed(ctxt->dict, attvalue, len);
|
||||
uri = huri.name;
|
||||
if (uri == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
goto next_attr;
|
||||
}
|
||||
if (*uri != 0) {
|
||||
if (xmlParseURISafe((const char *) uri, &parsedUri) < 0) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
goto next_attr;
|
||||
}
|
||||
if (parsedUri == NULL) {
|
||||
@ -9479,7 +9459,7 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,
|
||||
huri = xmlDictLookupHashed(ctxt->dict, attvalue, len);
|
||||
uri = huri.name;
|
||||
if (uri == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
goto next_attr;
|
||||
}
|
||||
|
||||
@ -9523,7 +9503,7 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,
|
||||
goto next_attr;
|
||||
} else {
|
||||
if (xmlParseURISafe((const char *) uri, &parsedUri) < 0) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
goto next_attr;
|
||||
}
|
||||
if (parsedUri == NULL) {
|
||||
@ -9683,7 +9663,7 @@ next_attr:
|
||||
|
||||
tmp = xmlRealloc(ctxt->attrHash, attrHashSize * sizeof(tmp[0]));
|
||||
if (tmp == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
goto done;
|
||||
}
|
||||
|
||||
@ -10006,7 +9986,7 @@ xmlParseCDSect(xmlParserCtxtPtr ctxt) {
|
||||
cur = CUR_CHAR(l);
|
||||
buf = (xmlChar *) xmlMallocAtomic(size);
|
||||
if (buf == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
goto out;
|
||||
}
|
||||
while (IS_CHAR(cur) &&
|
||||
@ -10016,7 +9996,7 @@ xmlParseCDSect(xmlParserCtxtPtr ctxt) {
|
||||
|
||||
tmp = (xmlChar *) xmlRealloc(buf, size * 2);
|
||||
if (tmp == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
goto out;
|
||||
}
|
||||
buf = tmp;
|
||||
@ -10385,7 +10365,7 @@ xmlParseVersionNum(xmlParserCtxtPtr ctxt) {
|
||||
|
||||
buf = (xmlChar *) xmlMallocAtomic(size);
|
||||
if (buf == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
cur = CUR;
|
||||
@ -10411,7 +10391,7 @@ xmlParseVersionNum(xmlParserCtxtPtr ctxt) {
|
||||
tmp = (xmlChar *) xmlRealloc(buf, size);
|
||||
if (tmp == NULL) {
|
||||
xmlFree(buf);
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
buf = tmp;
|
||||
@ -10500,7 +10480,7 @@ xmlParseEncName(xmlParserCtxtPtr ctxt) {
|
||||
((cur >= 'A') && (cur <= 'Z'))) {
|
||||
buf = (xmlChar *) xmlMallocAtomic(size);
|
||||
if (buf == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
@ -10518,7 +10498,7 @@ xmlParseEncName(xmlParserCtxtPtr ctxt) {
|
||||
size *= 2;
|
||||
tmp = (xmlChar *) xmlRealloc(buf, size);
|
||||
if (tmp == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
xmlFree(buf);
|
||||
return(NULL);
|
||||
}
|
||||
@ -10897,7 +10877,7 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
|
||||
} else {
|
||||
ctxt->version = xmlCharStrdup(XML_DEFAULT_VERSION);
|
||||
if (ctxt->version == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
@ -11499,14 +11479,14 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
||||
} else {
|
||||
ctxt->version = xmlCharStrdup(XML_DEFAULT_VERSION);
|
||||
if (ctxt->version == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ctxt->version = xmlCharStrdup(XML_DEFAULT_VERSION);
|
||||
if (ctxt->version == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -11888,7 +11868,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
|
||||
"PP: internal error\n");
|
||||
ctxt->instate = XML_PARSER_EOF;
|
||||
break;
|
||||
@ -12244,7 +12224,7 @@ xmlIOParseDTD(xmlSAXHandlerPtr sax, xmlParserInputBufferPtr input,
|
||||
ctxt->inSubset = 2;
|
||||
ctxt->myDoc = xmlNewDoc(BAD_CAST "1.0");
|
||||
if (ctxt->myDoc == NULL) {
|
||||
xmlErrMemory(ctxt, "New Doc failed");
|
||||
xmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
ctxt->myDoc->properties = XML_DOC_INTERNAL;
|
||||
@ -12357,7 +12337,7 @@ xmlSAXParseDTD(xmlSAXHandlerPtr sax, const xmlChar *ExternalID,
|
||||
ctxt->inSubset = 2;
|
||||
ctxt->myDoc = xmlNewDoc(BAD_CAST "1.0");
|
||||
if (ctxt->myDoc == NULL) {
|
||||
xmlErrMemory(ctxt, "New Doc failed");
|
||||
xmlErrMemory(ctxt);
|
||||
xmlFreeParserCtxt(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
@ -12511,7 +12491,7 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
|
||||
|
||||
newDoc = xmlNewDoc(BAD_CAST "1.0");
|
||||
if (newDoc == NULL) {
|
||||
xmlErrMemory(oldctxt, NULL);
|
||||
xmlErrMemory(oldctxt);
|
||||
goto error;
|
||||
}
|
||||
newDoc->properties = XML_DOC_INTERNAL;
|
||||
@ -12525,14 +12505,14 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
|
||||
if (doc->URL != NULL) {
|
||||
newDoc->URL = xmlStrdup(doc->URL);
|
||||
if (newDoc->URL == NULL) {
|
||||
xmlErrMemory(oldctxt, NULL);
|
||||
xmlErrMemory(oldctxt);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
}
|
||||
newRoot = xmlNewDocNode(newDoc, NULL, BAD_CAST "pseudoroot", NULL);
|
||||
if (newRoot == NULL) {
|
||||
xmlErrMemory(oldctxt, NULL);
|
||||
xmlErrMemory(oldctxt);
|
||||
goto error;
|
||||
}
|
||||
xmlAddChild((xmlNodePtr) newDoc, newRoot);
|
||||
@ -12668,7 +12648,7 @@ error:
|
||||
if (ctxt->disableSAX > oldctxt->disableSAX)
|
||||
oldctxt->disableSAX = ctxt->disableSAX;
|
||||
if (xmlCopyError(&ctxt->lastError, &oldctxt->lastError) < 0) {
|
||||
xmlErrMemory(oldctxt, NULL);
|
||||
xmlErrMemory(oldctxt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -12788,14 +12768,18 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
|
||||
|
||||
ctxt = xmlCreateDocParserCtxt(string);
|
||||
if (ctxt == NULL) {
|
||||
xmlErrMemory(oldctxt, NULL);
|
||||
xmlErrMemory(oldctxt);
|
||||
return(XML_ERR_NO_MEMORY);
|
||||
}
|
||||
|
||||
if (oldctxt->errorHandler != NULL)
|
||||
xmlCtxtSetErrorHandler(ctxt, oldctxt->errorHandler,
|
||||
oldctxt->errorCtxt);
|
||||
|
||||
if (oldctxt->myDoc == NULL) {
|
||||
newDoc = xmlNewDoc(BAD_CAST "1.0");
|
||||
if (newDoc == NULL) {
|
||||
xmlErrMemory(oldctxt, NULL);
|
||||
xmlErrMemory(oldctxt);
|
||||
ret = XML_ERR_NO_MEMORY;
|
||||
goto error;
|
||||
}
|
||||
@ -12810,7 +12794,7 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
|
||||
}
|
||||
newRoot = xmlNewDocNode(ctxt->myDoc, NULL, BAD_CAST "pseudoroot", NULL);
|
||||
if (newRoot == NULL) {
|
||||
xmlErrMemory(oldctxt, NULL);
|
||||
xmlErrMemory(oldctxt);
|
||||
ret = XML_ERR_NO_MEMORY;
|
||||
goto error;
|
||||
}
|
||||
@ -12911,7 +12895,7 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
|
||||
if (ctxt->disableSAX > oldctxt->disableSAX)
|
||||
oldctxt->disableSAX = ctxt->disableSAX;
|
||||
if (xmlCopyError(&ctxt->lastError, &oldctxt->lastError) < 0) {
|
||||
xmlErrMemory(oldctxt, NULL);
|
||||
xmlErrMemory(oldctxt);
|
||||
ret = XML_ERR_NO_MEMORY;
|
||||
}
|
||||
} else {
|
||||
@ -13437,11 +13421,14 @@ xmlCreateEntityParserCtxtInternal(xmlSAXHandlerPtr sax, void *userData,
|
||||
|
||||
ctxt = xmlNewSAXParserCtxt(sax, userData);
|
||||
if (ctxt == NULL) {
|
||||
xmlErrMemory(pctx, NULL);
|
||||
xmlErrMemory(pctx);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if (pctx != NULL) {
|
||||
if (pctx->errorHandler != NULL)
|
||||
xmlCtxtSetErrorHandler(ctxt, pctx->errorHandler, pctx->errorCtxt);
|
||||
|
||||
ctxt->options = pctx->options;
|
||||
ctxt->_private = pctx->_private;
|
||||
ctxt->input_id = pctx->input_id;
|
||||
@ -13453,7 +13440,7 @@ xmlCreateEntityParserCtxtInternal(xmlSAXHandlerPtr sax, void *userData,
|
||||
|
||||
if (base != NULL) {
|
||||
if (xmlBuildURISafe(URL, base, &uri) < 0) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
goto error;
|
||||
}
|
||||
if (uri != NULL)
|
||||
@ -13469,7 +13456,7 @@ xmlCreateEntityParserCtxtInternal(xmlSAXHandlerPtr sax, void *userData,
|
||||
if (ctxt->directory == NULL) {
|
||||
ctxt->directory = xmlParserGetDirectory((char *)URL);
|
||||
if (ctxt->directory == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
@ -13480,7 +13467,7 @@ xmlCreateEntityParserCtxtInternal(xmlSAXHandlerPtr sax, void *userData,
|
||||
error:
|
||||
if (pctx != NULL) {
|
||||
if (xmlCopyError(&ctxt->lastError, &pctx->lastError) < 0) {
|
||||
xmlErrMemory(pctx, NULL);
|
||||
xmlErrMemory(pctx);
|
||||
} else {
|
||||
pctx->errNo = ctxt->errNo;
|
||||
if (ctxt->disableSAX > pctx->disableSAX)
|
||||
@ -14574,7 +14561,7 @@ xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding,
|
||||
(ctxt->input->filename == NULL)) {
|
||||
ctxt->input->filename = (char *) xmlStrdup((const xmlChar *) URL);
|
||||
if (ctxt->input->filename == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
@ -14871,7 +14858,7 @@ xmlCtxtReadMemory(xmlParserCtxtPtr ctxt, const char *buffer, int size,
|
||||
input = xmlParserInputBufferCreateStatic(buffer, size,
|
||||
XML_CHAR_ENCODING_NONE);
|
||||
if (input == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,6 @@
|
||||
* @version: the include version number
|
||||
*
|
||||
* check the compiled lib version against the include one.
|
||||
* This can warn or immediately kill the application
|
||||
*/
|
||||
void
|
||||
xmlCheckVersion(int version) {
|
||||
@ -71,15 +70,11 @@ xmlCheckVersion(int version) {
|
||||
xmlInitParser();
|
||||
|
||||
if ((myversion / 10000) != (version / 10000)) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Fatal: program compiled against libxml %d using libxml %d\n",
|
||||
(version / 10000), (myversion / 10000));
|
||||
fprintf(stderr,
|
||||
"Fatal: program compiled against libxml %d using libxml %d\n",
|
||||
(version / 10000), (myversion / 10000));
|
||||
}
|
||||
if ((myversion / 100) < (version / 100)) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
} else if ((myversion / 100) < (version / 100)) {
|
||||
fprintf(stderr,
|
||||
"Warning: program compiled against libxml %d using older %d\n",
|
||||
(version / 100), (myversion / 100));
|
||||
}
|
||||
@ -94,49 +89,56 @@ xmlCheckVersion(int version) {
|
||||
|
||||
|
||||
/**
|
||||
* xmlErrMemory:
|
||||
* xmlCtxtSetErrorHandler:
|
||||
* @ctxt: an XML parser context
|
||||
* @extra: extra information
|
||||
* @handler: error handler
|
||||
* @data: data for error handler
|
||||
*
|
||||
* Handle a redefinition of attribute error
|
||||
* Set an error handler for a parser context.
|
||||
*/
|
||||
void
|
||||
xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra ATTRIBUTE_UNUSED)
|
||||
xmlCtxtSetErrorHandler(xmlParserCtxtPtr ctxt, xmlStructuredErrorFunc handler,
|
||||
void *data)
|
||||
{
|
||||
xmlError *lastError = &xmlLastError;
|
||||
if (ctxt == NULL)
|
||||
return;
|
||||
ctxt->errorHandler = handler;
|
||||
ctxt->errorCtxt = data;
|
||||
}
|
||||
|
||||
xmlResetLastError();
|
||||
lastError->domain = XML_FROM_PARSER;
|
||||
lastError->code = XML_ERR_NO_MEMORY;
|
||||
lastError->level = XML_ERR_FATAL;
|
||||
/**
|
||||
* xmlCtxtErrMemory:
|
||||
* @ctxt: an XML parser context
|
||||
* @domain: domain
|
||||
*
|
||||
* Handle an out-of-memory error
|
||||
*/
|
||||
void
|
||||
xmlCtxtErrMemory(xmlParserCtxtPtr ctxt)
|
||||
{
|
||||
xmlStructuredErrorFunc schannel = NULL;
|
||||
xmlGenericErrorFunc channel = NULL;
|
||||
void *data;
|
||||
|
||||
ctxt->errNo = XML_ERR_NO_MEMORY;
|
||||
ctxt->instate = XML_PARSER_EOF; /* TODO: Remove after refactoring */
|
||||
ctxt->wellFormed = 0;
|
||||
ctxt->disableSAX = 2;
|
||||
|
||||
xmlResetError(&ctxt->lastError);
|
||||
ctxt->lastError.domain = XML_FROM_PARSER;
|
||||
ctxt->lastError.code = XML_ERR_NO_MEMORY;
|
||||
ctxt->lastError.level = XML_ERR_FATAL;
|
||||
|
||||
if ((ctxt->sax->initialized == XML_SAX2_MAGIC) &&
|
||||
if (ctxt->errorHandler) {
|
||||
schannel = ctxt->errorHandler;
|
||||
data = ctxt->errorCtxt;
|
||||
} else if ((ctxt->sax->initialized == XML_SAX2_MAGIC) &&
|
||||
(ctxt->sax->serror != NULL)) {
|
||||
ctxt->sax->serror(ctxt->userData, &ctxt->lastError);
|
||||
} else if (xmlStructuredError != NULL) {
|
||||
xmlStructuredError(ctxt->userData, &ctxt->lastError);
|
||||
schannel = ctxt->sax->serror;
|
||||
data = ctxt->userData;
|
||||
} else {
|
||||
xmlGenericErrorFunc channel = ctxt->sax->error;
|
||||
|
||||
if ((channel == xmlParserError) ||
|
||||
(channel == xmlParserWarning) ||
|
||||
(channel == xmlParserValidityError) ||
|
||||
(channel == xmlParserValidityWarning))
|
||||
channel = xmlGenericError;
|
||||
|
||||
if (channel != NULL)
|
||||
channel(ctxt->userData, "parser error : out of memory\n");
|
||||
channel = ctxt->sax->error;
|
||||
data = ctxt->userData;
|
||||
}
|
||||
|
||||
xmlRaiseMemoryError(schannel, channel, data, XML_FROM_PARSER,
|
||||
&ctxt->lastError);
|
||||
}
|
||||
|
||||
void
|
||||
@ -146,7 +148,7 @@ xmlVErrParser(xmlParserCtxtPtr ctxt, xmlNodePtr node,
|
||||
int int1, const char *msg, va_list ap)
|
||||
{
|
||||
xmlStructuredErrorFunc schannel = NULL;
|
||||
xmlGenericErrorFunc channel;
|
||||
xmlGenericErrorFunc channel = NULL;
|
||||
void *data;
|
||||
const char *file = NULL;
|
||||
int line = 0;
|
||||
@ -157,7 +159,7 @@ xmlVErrParser(xmlParserCtxtPtr ctxt, xmlNodePtr node,
|
||||
return;
|
||||
|
||||
if (code == XML_ERR_NO_MEMORY) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -171,10 +173,14 @@ xmlVErrParser(xmlParserCtxtPtr ctxt, xmlNodePtr node,
|
||||
ctxt->nbErrors += 1;
|
||||
}
|
||||
|
||||
if (ctxt->sax->initialized == XML_SAX2_MAGIC)
|
||||
if (ctxt->errorHandler) {
|
||||
schannel = ctxt->errorHandler;
|
||||
data = ctxt->errorCtxt;
|
||||
} else if ((ctxt->sax->initialized == XML_SAX2_MAGIC) &&
|
||||
(ctxt->sax->serror != NULL)) {
|
||||
schannel = ctxt->sax->serror;
|
||||
|
||||
if ((domain == XML_FROM_VALID) || (domain == XML_FROM_DTD)) {
|
||||
data = ctxt->userData;
|
||||
} else if ((domain == XML_FROM_VALID) || (domain == XML_FROM_DTD)) {
|
||||
if (level == XML_ERR_WARNING)
|
||||
channel = ctxt->vctxt.warning;
|
||||
else
|
||||
@ -206,7 +212,7 @@ xmlVErrParser(xmlParserCtxtPtr ctxt, xmlNodePtr node,
|
||||
msg, ap);
|
||||
|
||||
if (res < 0) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1357,7 +1363,7 @@ xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
|
||||
|
||||
buf = xmlBufCreate();
|
||||
if (buf == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
@ -1375,7 +1381,7 @@ xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
|
||||
nbchars = xmlCharEncInput(in);
|
||||
xmlBufResetInput(in->buffer, input);
|
||||
if (nbchars == XML_ENC_ERR_MEMORY) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
} else if (nbchars < 0) {
|
||||
xmlErrInternal(ctxt,
|
||||
"switching encoding: encoder error\n",
|
||||
@ -1573,7 +1579,7 @@ xmlSetDeclaredEncoding(xmlParserCtxtPtr ctxt, xmlChar *encoding) {
|
||||
xmlFree(encoding);
|
||||
encoding = xmlStrdup(BAD_CAST autoEnc);
|
||||
if (encoding == NULL)
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1623,7 +1629,7 @@ xmlNewInputStream(xmlParserCtxtPtr ctxt) {
|
||||
|
||||
input = (xmlParserInputPtr) xmlMalloc(sizeof(xmlParserInput));
|
||||
if (input == NULL) {
|
||||
xmlErrMemory(ctxt, "couldn't allocate a new input stream\n");
|
||||
xmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
memset(input, 0, sizeof(xmlParserInput));
|
||||
@ -1637,7 +1643,7 @@ xmlNewInputStream(xmlParserCtxtPtr ctxt) {
|
||||
*/
|
||||
if (ctxt != NULL) {
|
||||
if (input->id >= INT_MAX) {
|
||||
xmlErrMemory(ctxt, "Input ID overflow\n");
|
||||
xmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
input->id = ctxt->input_id++;
|
||||
@ -1663,8 +1669,6 @@ xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input,
|
||||
xmlParserInputPtr inputStream;
|
||||
|
||||
if (input == NULL) return(NULL);
|
||||
if (xmlParserDebugEntities)
|
||||
xmlGenericError(xmlGenericErrorContext, "new input from I/O\n");
|
||||
inputStream = xmlNewInputStream(ctxt);
|
||||
if (inputStream == NULL) {
|
||||
return(NULL);
|
||||
@ -1700,9 +1704,6 @@ xmlNewEntityInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
|
||||
NULL);
|
||||
return(NULL);
|
||||
}
|
||||
if (xmlParserDebugEntities)
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"new input from entity: %s\n", entity->name);
|
||||
if (entity->content == NULL) {
|
||||
switch (entity->etype) {
|
||||
case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY:
|
||||
@ -1768,17 +1769,14 @@ xmlNewStringInputStream(xmlParserCtxtPtr ctxt, const xmlChar *buffer) {
|
||||
NULL);
|
||||
return(NULL);
|
||||
}
|
||||
if (xmlParserDebugEntities)
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"new fixed input: %.30s\n", buffer);
|
||||
buf = xmlParserInputBufferCreateString(buffer);
|
||||
if (buf == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
input = xmlNewInputStream(ctxt);
|
||||
if (input == NULL) {
|
||||
xmlErrMemory(ctxt, "couldn't allocate a new input stream\n");
|
||||
xmlErrMemory(ctxt);
|
||||
xmlFreeParserInputBuffer(buf);
|
||||
return(NULL);
|
||||
}
|
||||
@ -1803,9 +1801,6 @@ xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) {
|
||||
char *directory = NULL;
|
||||
xmlChar *URI = NULL;
|
||||
|
||||
if (xmlParserDebugEntities)
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"new input from file: %s\n", filename);
|
||||
if (ctxt == NULL) return(NULL);
|
||||
buf = xmlParserInputBufferCreateFilename(filename, XML_CHAR_ENCODING_NONE);
|
||||
if (buf == NULL) {
|
||||
@ -2007,7 +2002,7 @@ xmlInitSAXParserCtxt(xmlParserCtxtPtr ctxt, const xmlSAXHandler *sax,
|
||||
if (ctxt->nsdb == NULL) {
|
||||
ctxt->nsdb = xmlParserNsCreate();
|
||||
if (ctxt->nsdb == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlErrMemory(ctxt);
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
@ -2341,7 +2336,7 @@ xmlParserAddNodeInfo(xmlParserCtxtPtr ctxt,
|
||||
byte_size);
|
||||
|
||||
if (tmp_buffer == NULL) {
|
||||
xmlErrMemory(ctxt, "failed to allocate buffer\n");
|
||||
xmlErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
ctxt->node_seq.buffer = tmp_buffer;
|
||||
|
100
valid.c
100
valid.c
@ -30,11 +30,6 @@
|
||||
static xmlElementPtr
|
||||
xmlGetDtdElementDesc2(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name);
|
||||
|
||||
#define TODO \
|
||||
xmlGenericError(xmlGenericErrorContext, \
|
||||
"Unimplemented block at %s:%d\n", \
|
||||
__FILE__, __LINE__);
|
||||
|
||||
#ifdef LIBXML_VALID_ENABLED
|
||||
static int
|
||||
xmlValidateAttributeValueInternal(xmlDocPtr doc, xmlAttributeType type,
|
||||
@ -54,21 +49,17 @@ xmlValidateAttributeValueInternal(xmlDocPtr doc, xmlAttributeType type,
|
||||
* Handle an out of memory error
|
||||
*/
|
||||
static void
|
||||
xmlVErrMemory(xmlValidCtxtPtr ctxt, const char *extra)
|
||||
xmlVErrMemory(xmlValidCtxtPtr ctxt)
|
||||
{
|
||||
if (ctxt != NULL) {
|
||||
if (ctxt->flags & XML_VCTXT_USE_PCTXT) {
|
||||
xmlParserCtxtPtr pctxt = ctxt->userData;
|
||||
|
||||
xmlErrMemory(pctxt, extra);
|
||||
xmlCtxtErrMemory(ctxt->userData);
|
||||
} else {
|
||||
xmlError *lastError = &xmlLastError;
|
||||
|
||||
xmlResetLastError();
|
||||
lastError->domain = XML_FROM_PARSER;
|
||||
lastError->code = XML_ERR_NO_MEMORY;
|
||||
lastError->level = XML_ERR_FATAL;
|
||||
xmlRaiseMemoryError(NULL, ctxt->error, ctxt->userData,
|
||||
XML_FROM_VALID, NULL);
|
||||
}
|
||||
} else {
|
||||
xmlRaiseMemoryError(NULL, NULL, NULL, XML_FROM_VALID, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,18 +82,19 @@ xmlDoErrValid(xmlValidCtxtPtr ctxt, xmlNodePtr node,
|
||||
} else {
|
||||
xmlGenericErrorFunc channel = NULL;
|
||||
void *data = NULL;
|
||||
int res;
|
||||
|
||||
if (ctxt != NULL) {
|
||||
channel = ctxt->error;
|
||||
data = ctxt->userData;
|
||||
}
|
||||
xmlVRaiseError(NULL, channel, data, NULL, node,
|
||||
XML_FROM_VALID, code, level,
|
||||
NULL, 0,
|
||||
(const char *) str1, (const char *) str2,
|
||||
(const char *) str2,
|
||||
int1, 0,
|
||||
msg, ap);
|
||||
res = xmlVRaiseError(NULL, channel, data, NULL, node,
|
||||
XML_FROM_VALID, code, level, NULL, 0,
|
||||
(const char *) str1, (const char *) str2,
|
||||
(const char *) str2, int1, 0,
|
||||
msg, ap);
|
||||
if (res < 0)
|
||||
xmlVErrMemory(ctxt);
|
||||
}
|
||||
va_end(ap);
|
||||
}
|
||||
@ -215,7 +207,7 @@ vstateVPush(xmlValidCtxtPtr ctxt, xmlElementPtr elemDecl, xmlNodePtr node) {
|
||||
ctxt->vstateTab = (xmlValidState *) xmlMalloc(ctxt->vstateMax *
|
||||
sizeof(ctxt->vstateTab[0]));
|
||||
if (ctxt->vstateTab == NULL) {
|
||||
xmlVErrMemory(ctxt, "malloc failed");
|
||||
xmlVErrMemory(ctxt);
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
@ -226,7 +218,7 @@ vstateVPush(xmlValidCtxtPtr ctxt, xmlElementPtr elemDecl, xmlNodePtr node) {
|
||||
tmp = (xmlValidState *) xmlRealloc(ctxt->vstateTab,
|
||||
2 * ctxt->vstateMax * sizeof(ctxt->vstateTab[0]));
|
||||
if (tmp == NULL) {
|
||||
xmlVErrMemory(ctxt, "realloc failed");
|
||||
xmlVErrMemory(ctxt);
|
||||
return(-1);
|
||||
}
|
||||
ctxt->vstateMax *= 2;
|
||||
@ -242,7 +234,7 @@ vstateVPush(xmlValidCtxtPtr ctxt, xmlElementPtr elemDecl, xmlNodePtr node) {
|
||||
ctxt->vstateTab[ctxt->vstateNr].exec =
|
||||
xmlRegNewExecCtxt(elemDecl->contModel, NULL, NULL);
|
||||
if (ctxt->vstateTab[ctxt->vstateNr].exec == NULL) {
|
||||
xmlVErrMemory(ctxt, NULL);
|
||||
xmlVErrMemory(ctxt);
|
||||
return(-1);
|
||||
}
|
||||
} else {
|
||||
@ -326,7 +318,7 @@ vstateVPush(xmlValidCtxtPtr ctxt, xmlElementContentPtr cont,
|
||||
ctxt->vstateTab = (xmlValidState *) xmlMalloc(
|
||||
ctxt->vstateMax * sizeof(ctxt->vstateTab[0]));
|
||||
if (ctxt->vstateTab == NULL) {
|
||||
xmlVErrMemory(ctxt, "malloc failed");
|
||||
xmlVErrMemory(ctxt);
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
@ -336,7 +328,7 @@ vstateVPush(xmlValidCtxtPtr ctxt, xmlElementContentPtr cont,
|
||||
tmp = (xmlValidState *) xmlRealloc(ctxt->vstateTab,
|
||||
2 * ctxt->vstateMax * sizeof(ctxt->vstateTab[0]));
|
||||
if (tmp == NULL) {
|
||||
xmlVErrMemory(ctxt, "malloc failed");
|
||||
xmlVErrMemory(ctxt);
|
||||
return(-1);
|
||||
}
|
||||
ctxt->vstateMax *= 2;
|
||||
@ -384,7 +376,7 @@ nodeVPush(xmlValidCtxtPtr ctxt, xmlNodePtr value)
|
||||
(xmlNodePtr *) xmlMalloc(ctxt->nodeMax *
|
||||
sizeof(ctxt->nodeTab[0]));
|
||||
if (ctxt->nodeTab == NULL) {
|
||||
xmlVErrMemory(ctxt, "malloc failed");
|
||||
xmlVErrMemory(ctxt);
|
||||
ctxt->nodeMax = 0;
|
||||
return (0);
|
||||
}
|
||||
@ -394,7 +386,7 @@ nodeVPush(xmlValidCtxtPtr ctxt, xmlNodePtr value)
|
||||
tmp = (xmlNodePtr *) xmlRealloc(ctxt->nodeTab,
|
||||
ctxt->nodeMax * 2 * sizeof(ctxt->nodeTab[0]));
|
||||
if (tmp == NULL) {
|
||||
xmlVErrMemory(ctxt, "realloc failed");
|
||||
xmlVErrMemory(ctxt);
|
||||
return (0);
|
||||
}
|
||||
ctxt->nodeMax *= 2;
|
||||
@ -471,7 +463,7 @@ xmlValidBuildAContentModel(xmlElementContentPtr content,
|
||||
|
||||
fullname = xmlBuildQName(content->name, content->prefix, fn, 50);
|
||||
if (fullname == NULL) {
|
||||
xmlVErrMemory(ctxt, "Building content model");
|
||||
xmlVErrMemory(ctxt);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@ -622,7 +614,7 @@ xmlValidBuildContentModel(xmlValidCtxtPtr ctxt, xmlElementPtr elem) {
|
||||
|
||||
ctxt->am = xmlNewAutomata();
|
||||
if (ctxt->am == NULL) {
|
||||
xmlVErrMemory(ctxt, NULL);
|
||||
xmlVErrMemory(ctxt);
|
||||
return(0);
|
||||
}
|
||||
ctxt->state = xmlAutomataGetInitState(ctxt->am);
|
||||
@ -630,7 +622,7 @@ xmlValidBuildContentModel(xmlValidCtxtPtr ctxt, xmlElementPtr elem) {
|
||||
xmlAutomataSetFinalState(ctxt->am, ctxt->state);
|
||||
elem->contModel = xmlAutomataCompile(ctxt->am);
|
||||
if (elem->contModel == NULL) {
|
||||
xmlVErrMemory(ctxt, NULL);
|
||||
xmlVErrMemory(ctxt);
|
||||
goto done;
|
||||
}
|
||||
if (xmlRegexpIsDeterminist(elem->contModel) != 1) {
|
||||
@ -1428,7 +1420,7 @@ xmlAddElementDecl(xmlValidCtxtPtr ctxt,
|
||||
return(ret);
|
||||
|
||||
mem_error:
|
||||
xmlVErrMemory(ctxt, NULL);
|
||||
xmlVErrMemory(ctxt);
|
||||
if (prefix != NULL)
|
||||
xmlFree(prefix);
|
||||
return(NULL);
|
||||
@ -1933,7 +1925,7 @@ xmlAddAttributeDecl(xmlValidCtxtPtr ctxt,
|
||||
else
|
||||
ret->defaultValue = xmlStrdup(defaultValue);
|
||||
if (ret->defaultValue == NULL)
|
||||
xmlVErrMemory(ctxt, NULL);
|
||||
xmlVErrMemory(ctxt);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2019,7 +2011,7 @@ xmlAddAttributeDecl(xmlValidCtxtPtr ctxt,
|
||||
return(ret);
|
||||
|
||||
mem_error:
|
||||
xmlVErrMemory(ctxt, "malloc failed");
|
||||
xmlVErrMemory(ctxt);
|
||||
xmlFreeEnumeration(tree);
|
||||
xmlFreeAttribute(ret);
|
||||
return(NULL);
|
||||
@ -2329,7 +2321,7 @@ xmlAddNotationDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd,
|
||||
return(ret);
|
||||
|
||||
mem_error:
|
||||
xmlVErrMemory(ctxt, "malloc failed");
|
||||
xmlVErrMemory(ctxt);
|
||||
xmlFreeNotation(ret);
|
||||
return(NULL);
|
||||
}
|
||||
@ -2621,7 +2613,7 @@ xmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
|
||||
|
||||
res = xmlAddIDSafe(doc, value, attr, xmlIsStreaming(ctxt), &id);
|
||||
if (res < 0) {
|
||||
xmlVErrMemory(ctxt, "malloc failed");
|
||||
xmlVErrMemory(ctxt);
|
||||
}
|
||||
#ifdef LIBXML_VALID_ENABLED
|
||||
else if (res == 0) {
|
||||
@ -2961,7 +2953,7 @@ xmlAddRef(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
|
||||
return(ret);
|
||||
|
||||
failed:
|
||||
xmlVErrMemory(ctxt, NULL);
|
||||
xmlVErrMemory(ctxt);
|
||||
if (ret != NULL) {
|
||||
if (ret->value != NULL)
|
||||
xmlFree((char *)ret->value);
|
||||
@ -3224,7 +3216,7 @@ xmlGetDtdElementDesc2(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name)
|
||||
return(cur);
|
||||
|
||||
mem_error:
|
||||
xmlVErrMemory(ctxt, NULL);
|
||||
xmlVErrMemory(ctxt);
|
||||
xmlFree(prefix);
|
||||
xmlFreeElement(cur);
|
||||
return(NULL);
|
||||
@ -3464,7 +3456,7 @@ xmlCtxtGetDtdElementDesc(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd,
|
||||
|
||||
localName = xmlSplitQName4(name, &prefix);
|
||||
if (localName == NULL) {
|
||||
xmlVErrMemory(ctxt, NULL);
|
||||
xmlVErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
cur = xmlHashLookup2(table, localName, prefix);
|
||||
@ -3944,7 +3936,7 @@ xmlValidateAttributeValue2(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
|
||||
|
||||
dup = xmlStrdup(value);
|
||||
if (dup == NULL) {
|
||||
xmlVErrMemory(ctxt, NULL);
|
||||
xmlVErrMemory(ctxt);
|
||||
return(0);
|
||||
}
|
||||
cur = dup;
|
||||
@ -4086,7 +4078,7 @@ xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
|
||||
return(ret);
|
||||
|
||||
mem_error:
|
||||
xmlVErrMemory(ctxt, NULL);
|
||||
xmlVErrMemory(ctxt);
|
||||
|
||||
done:
|
||||
xmlFree(prefix);
|
||||
@ -4429,7 +4421,7 @@ xmlValidateOneAttribute(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
|
||||
|
||||
fullname = xmlBuildQName(elem->name, elem->ns->prefix, fn, 50);
|
||||
if (fullname == NULL) {
|
||||
xmlVErrMemory(ctxt, NULL);
|
||||
xmlVErrMemory(ctxt);
|
||||
return(0);
|
||||
}
|
||||
attrDecl = xmlGetDtdQAttrDesc(doc->intSubset, fullname,
|
||||
@ -4593,7 +4585,7 @@ xmlNodePtr elem, const xmlChar *prefix, xmlNsPtr ns, const xmlChar *value) {
|
||||
|
||||
fullname = xmlBuildQName(elem->name, prefix, fn, 50);
|
||||
if (fullname == NULL) {
|
||||
xmlVErrMemory(ctxt, "Validating namespace");
|
||||
xmlVErrMemory(ctxt);
|
||||
return(0);
|
||||
}
|
||||
if (ns->prefix != NULL) {
|
||||
@ -5274,7 +5266,7 @@ xmlValidateElementContent(xmlValidCtxtPtr ctxt, xmlNodePtr child,
|
||||
ctxt->nodeTab = NULL;
|
||||
exec = xmlRegNewExecCtxt(elemDecl->contModel, NULL, NULL);
|
||||
if (exec == NULL) {
|
||||
xmlVErrMemory(ctxt, NULL);
|
||||
xmlVErrMemory(ctxt);
|
||||
return(-1);
|
||||
}
|
||||
cur = child;
|
||||
@ -5309,7 +5301,7 @@ xmlValidateElementContent(xmlValidCtxtPtr ctxt, xmlNodePtr child,
|
||||
fullname = xmlBuildQName(cur->name,
|
||||
cur->ns->prefix, fn, 50);
|
||||
if (fullname == NULL) {
|
||||
xmlVErrMemory(ctxt, NULL);
|
||||
xmlVErrMemory(ctxt);
|
||||
ret = -1;
|
||||
goto fail;
|
||||
}
|
||||
@ -5324,7 +5316,7 @@ xmlValidateElementContent(xmlValidCtxtPtr ctxt, xmlNodePtr child,
|
||||
break;
|
||||
}
|
||||
if (ret == XML_REGEXP_OUT_OF_MEMORY)
|
||||
xmlVErrMemory(ctxt, NULL);
|
||||
xmlVErrMemory(ctxt);
|
||||
/*
|
||||
* Switch to next element
|
||||
*/
|
||||
@ -5348,7 +5340,7 @@ fail:
|
||||
ctxt->vstateTab = (xmlValidState *) xmlMalloc(
|
||||
ctxt->vstateMax * sizeof(ctxt->vstateTab[0]));
|
||||
if (ctxt->vstateTab == NULL) {
|
||||
xmlVErrMemory(ctxt, "malloc failed");
|
||||
xmlVErrMemory(ctxt);
|
||||
return(-1);
|
||||
}
|
||||
/*
|
||||
@ -5407,7 +5399,7 @@ fail:
|
||||
*/
|
||||
tmp = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
|
||||
if (tmp == NULL) {
|
||||
xmlVErrMemory(ctxt, "malloc failed");
|
||||
xmlVErrMemory(ctxt);
|
||||
xmlFreeNodeList(repl);
|
||||
ret = -1;
|
||||
goto done;
|
||||
@ -5800,7 +5792,7 @@ xmlValidatePushElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
|
||||
if (state->exec != NULL) {
|
||||
ret = xmlRegExecPushString(state->exec, qname, NULL);
|
||||
if (ret == XML_REGEXP_OUT_OF_MEMORY) {
|
||||
xmlVErrMemory(ctxt, NULL);
|
||||
xmlVErrMemory(ctxt);
|
||||
return(0);
|
||||
}
|
||||
if (ret < 0) {
|
||||
@ -6361,7 +6353,7 @@ xmlValidateRoot(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
|
||||
|
||||
fullname = xmlBuildQName(root->name, root->ns->prefix, fn, 50);
|
||||
if (fullname == NULL) {
|
||||
xmlVErrMemory(ctxt, NULL);
|
||||
xmlVErrMemory(ctxt);
|
||||
return(0);
|
||||
}
|
||||
ret = xmlStrEqual(doc->intSubset->name, fullname);
|
||||
@ -6416,7 +6408,7 @@ xmlValidateElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr root) {
|
||||
while (attr != NULL) {
|
||||
value = xmlNodeListGetString(doc, attr->children, 0);
|
||||
if (value == NULL)
|
||||
xmlVErrMemory(ctxt, NULL);
|
||||
xmlVErrMemory(ctxt);
|
||||
ret &= xmlValidateOneAttribute(ctxt, doc, elem, attr, value);
|
||||
if (value != NULL)
|
||||
xmlFree((char *)value);
|
||||
@ -6478,7 +6470,7 @@ xmlValidateRef(xmlRefPtr ref, xmlValidCtxtPtr ctxt,
|
||||
|
||||
dup = xmlStrdup(name);
|
||||
if (dup == NULL) {
|
||||
xmlVErrMemory(ctxt, NULL);
|
||||
xmlVErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
cur = dup;
|
||||
@ -6513,7 +6505,7 @@ xmlValidateRef(xmlRefPtr ref, xmlValidCtxtPtr ctxt,
|
||||
|
||||
dup = xmlStrdup(name);
|
||||
if (dup == NULL) {
|
||||
xmlVErrMemory(ctxt, "IDREFS split");
|
||||
xmlVErrMemory(ctxt);
|
||||
ctxt->valid = 0;
|
||||
return;
|
||||
}
|
||||
|
24
xmlIO.c
24
xmlIO.c
@ -202,7 +202,6 @@ __xmlIOWin32UTF8ToWChar(const char *u8String)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(LIBXML_HTTP_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
|
||||
/**
|
||||
* xmlIOErrMemory:
|
||||
* @extra: extra information
|
||||
@ -210,11 +209,10 @@ __xmlIOWin32UTF8ToWChar(const char *u8String)
|
||||
* Handle an out of memory condition
|
||||
*/
|
||||
static void
|
||||
xmlIOErrMemory(const char *extra)
|
||||
xmlIOErrMemory(void)
|
||||
{
|
||||
__xmlSimpleError(XML_FROM_IO, XML_ERR_NO_MEMORY, NULL, NULL, extra);
|
||||
xmlRaiseMemoryError(NULL, NULL, NULL, XML_FROM_IO, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* __xmlIOErr:
|
||||
@ -228,6 +226,7 @@ void
|
||||
__xmlIOErr(int domain, int code, const char *extra)
|
||||
{
|
||||
unsigned int idx;
|
||||
int res;
|
||||
|
||||
if (code == 0) {
|
||||
if (errno == 0) code = 0;
|
||||
@ -390,7 +389,12 @@ __xmlIOErr(int domain, int code, const char *extra)
|
||||
if (code >= XML_IO_UNKNOWN) idx = code - XML_IO_UNKNOWN;
|
||||
if (idx >= (sizeof(IOerr) / sizeof(IOerr[0]))) idx = 0;
|
||||
|
||||
__xmlSimpleError(domain, code, NULL, IOerr[idx], extra);
|
||||
res = __xmlRaiseError(NULL, NULL, NULL, NULL, NULL,
|
||||
domain, code, XML_ERR_ERROR, NULL, 0,
|
||||
extra, NULL, NULL, 0, 0,
|
||||
IOerr[idx], extra);
|
||||
if (res < 0)
|
||||
xmlIOErrMemory();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1460,7 +1464,7 @@ xmlCreateZMemBuff( int compression ) {
|
||||
|
||||
buff = xmlMalloc( sizeof( xmlZMemBuff ) );
|
||||
if ( buff == NULL ) {
|
||||
xmlIOErrMemory("creating buffer context");
|
||||
xmlIOErrMemory();
|
||||
return ( NULL );
|
||||
}
|
||||
|
||||
@ -1469,7 +1473,7 @@ xmlCreateZMemBuff( int compression ) {
|
||||
buff->zbuff = xmlMalloc( buff->size );
|
||||
if ( buff->zbuff == NULL ) {
|
||||
xmlFreeZMemBuff( buff );
|
||||
xmlIOErrMemory("creating buffer");
|
||||
xmlIOErrMemory();
|
||||
return ( NULL );
|
||||
}
|
||||
|
||||
@ -1753,7 +1757,7 @@ xmlIOHTTPOpenW(const char *post_uri, int compression ATTRIBUTE_UNUSED)
|
||||
|
||||
ctxt = xmlMalloc(sizeof(xmlIOHTTPWriteCtxt));
|
||||
if (ctxt == NULL) {
|
||||
xmlIOErrMemory("creating HTTP output context");
|
||||
xmlIOErrMemory();
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
@ -1761,7 +1765,7 @@ xmlIOHTTPOpenW(const char *post_uri, int compression ATTRIBUTE_UNUSED)
|
||||
|
||||
ctxt->uri = (char *) xmlStrdup((const xmlChar *)post_uri);
|
||||
if (ctxt->uri == NULL) {
|
||||
xmlIOErrMemory("copying URI");
|
||||
xmlIOErrMemory();
|
||||
xmlFreeHTTPWriteCtxt(ctxt);
|
||||
return (NULL);
|
||||
}
|
||||
@ -4009,7 +4013,7 @@ xmlLoadExternalEntity(const char *URL, const char *ID,
|
||||
|
||||
canonicFilename = (char *) xmlCanonicPath((const xmlChar *) URL);
|
||||
if (canonicFilename == NULL) {
|
||||
xmlErrMemory(ctxt, "building canonical path\n");
|
||||
xmlCtxtErrMemory(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ static void xmlTextReaderFreeNodeList(xmlTextReaderPtr reader, xmlNodePtr cur);
|
||||
|
||||
static void
|
||||
xmlTextReaderErrMemory(xmlTextReaderPtr reader) {
|
||||
xmlErrMemory(reader->ctxt, NULL);
|
||||
xmlCtxtErrMemory(reader->ctxt);
|
||||
reader->mode = XML_TEXTREADER_MODE_ERROR;
|
||||
reader->state = XML_TEXTREADER_ERROR;
|
||||
}
|
||||
|
@ -4509,7 +4509,7 @@ xmlTextWriterStartDocumentCallback(void *ctx)
|
||||
if (ctxt->myDoc == NULL)
|
||||
ctxt->myDoc = htmlNewDocNoDtD(NULL, NULL);
|
||||
if (ctxt->myDoc == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlCtxtErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
} else
|
||||
@ -4527,7 +4527,7 @@ xmlTextWriterStartDocumentCallback(void *ctx)
|
||||
doc->standalone = ctxt->standalone;
|
||||
}
|
||||
} else {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlCtxtErrMemory(ctxt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user