Commit d0b03aa2 authored by Alexandre Julliard's avatar Alexandre Julliard

xml2: Import upstream release 2.10.3.

parent fd3017ff
......@@ -5056,8 +5056,7 @@ htmlInitParserCtxt(htmlParserCtxtPtr ctxt)
htmlErrMemory(NULL, "htmlInitParserCtxt: out of memory\n");
return(-1);
}
else
memset(sax, 0, sizeof(htmlSAXHandler));
memset(sax, 0, sizeof(htmlSAXHandler));
/* Allocate the Input stack */
ctxt->inputTab = (htmlParserInputPtr *)
......@@ -5116,11 +5115,9 @@ htmlInitParserCtxt(htmlParserCtxtPtr ctxt)
ctxt->nodeInfoNr = 0;
ctxt->nodeInfoMax = 0;
if (sax == NULL) ctxt->sax = (xmlSAXHandlerPtr) &htmlDefaultSAXHandler;
else {
ctxt->sax = sax;
memcpy(sax, &htmlDefaultSAXHandler, sizeof(xmlSAXHandlerV1));
}
ctxt->sax = sax;
xmlSAX2InitHtmlDefaultSAXHandler(sax);
ctxt->userData = ctxt;
ctxt->myDoc = NULL;
ctxt->wellFormed = 1;
......@@ -7116,22 +7113,10 @@ htmlDocPtr
htmlCtxtReadDoc(htmlParserCtxtPtr ctxt, const xmlChar * cur,
const char *URL, const char *encoding, int options)
{
xmlParserInputPtr stream;
if (cur == NULL)
return (NULL);
if (ctxt == NULL)
return (NULL);
xmlInitParser();
htmlCtxtReset(ctxt);
stream = xmlNewStringInputStream(ctxt, cur);
if (stream == NULL) {
return (NULL);
}
inputPush(ctxt, stream);
return (htmlDoRead(ctxt, URL, encoding, options, 1));
return (htmlCtxtReadMemory(ctxt, (const char *) cur, xmlStrlen(cur), URL,
encoding, options));
}
/**
......
......@@ -28,11 +28,6 @@
#include <libxml/HTMLtree.h>
#include <libxml/globals.h>
/* Define SIZE_T_MAX unless defined through <limits.h>. */
#ifndef SIZE_T_MAX
# define SIZE_T_MAX ((size_t)-1)
#endif /* !SIZE_T_MAX */
/* #define DEBUG_SAX2 */
/* #define DEBUG_SAX2_TREE */
......@@ -2596,22 +2591,23 @@ xmlSAX2Text(xmlParserCtxtPtr ctxt, const xmlChar *ch, int len,
xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters: xmlStrdup returned NULL");
return;
}
if (((size_t)ctxt->nodelen + (size_t)len > XML_MAX_TEXT_LENGTH) &&
if (ctxt->nodelen > INT_MAX - len) {
xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters overflow prevented");
return;
}
if ((ctxt->nodelen + len > XML_MAX_TEXT_LENGTH) &&
((ctxt->options & XML_PARSE_HUGE) == 0)) {
xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters: huge text node");
return;
}
if ((size_t)ctxt->nodelen > SIZE_T_MAX - (size_t)len ||
(size_t)ctxt->nodemem + (size_t)len > SIZE_T_MAX / 2) {
xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters overflow prevented");
return;
}
if (ctxt->nodelen + len >= ctxt->nodemem) {
xmlChar *newbuf;
size_t size;
int size;
size = ctxt->nodemem + len;
size *= 2;
size = ctxt->nodemem > INT_MAX - len ?
INT_MAX :
ctxt->nodemem + len;
size = size > INT_MAX / 2 ? INT_MAX : size * 2;
newbuf = (xmlChar *) xmlRealloc(lastChild->content,size);
if (newbuf == NULL) {
xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters");
......
......@@ -128,36 +128,19 @@ xmlFreeEntity(xmlEntityPtr entity)
if ((entity->children) && (entity->owner == 1) &&
(entity == (xmlEntityPtr) entity->children->parent))
xmlFreeNodeList(entity->children);
if (dict != NULL) {
if ((entity->name != NULL) && (!xmlDictOwns(dict, entity->name)))
xmlFree((char *) entity->name);
if ((entity->ExternalID != NULL) &&
(!xmlDictOwns(dict, entity->ExternalID)))
xmlFree((char *) entity->ExternalID);
if ((entity->SystemID != NULL) &&
(!xmlDictOwns(dict, entity->SystemID)))
xmlFree((char *) entity->SystemID);
if ((entity->URI != NULL) && (!xmlDictOwns(dict, entity->URI)))
xmlFree((char *) entity->URI);
if ((entity->content != NULL)
&& (!xmlDictOwns(dict, entity->content)))
xmlFree((char *) entity->content);
if ((entity->orig != NULL) && (!xmlDictOwns(dict, entity->orig)))
xmlFree((char *) entity->orig);
} else {
if (entity->name != NULL)
xmlFree((char *) entity->name);
if (entity->ExternalID != NULL)
xmlFree((char *) entity->ExternalID);
if (entity->SystemID != NULL)
xmlFree((char *) entity->SystemID);
if (entity->URI != NULL)
xmlFree((char *) entity->URI);
if (entity->content != NULL)
xmlFree((char *) entity->content);
if (entity->orig != NULL)
xmlFree((char *) entity->orig);
}
if ((entity->name != NULL) &&
((dict == NULL) || (!xmlDictOwns(dict, entity->name))))
xmlFree((char *) entity->name);
if (entity->ExternalID != NULL)
xmlFree((char *) entity->ExternalID);
if (entity->SystemID != NULL)
xmlFree((char *) entity->SystemID);
if (entity->URI != NULL)
xmlFree((char *) entity->URI);
if (entity->content != NULL)
xmlFree((char *) entity->content);
if (entity->orig != NULL)
xmlFree((char *) entity->orig);
xmlFree(entity);
}
......@@ -193,18 +176,12 @@ xmlCreateEntity(xmlDictPtr dict, const xmlChar *name, int type,
ret->SystemID = xmlStrdup(SystemID);
} else {
ret->name = xmlDictLookup(dict, name, -1);
if (ExternalID != NULL)
ret->ExternalID = xmlDictLookup(dict, ExternalID, -1);
if (SystemID != NULL)
ret->SystemID = xmlDictLookup(dict, SystemID, -1);
ret->ExternalID = xmlStrdup(ExternalID);
ret->SystemID = xmlStrdup(SystemID);
}
if (content != NULL) {
ret->length = xmlStrlen(content);
if ((dict != NULL) && (ret->length < 5))
ret->content = (xmlChar *)
xmlDictLookup(dict, content, ret->length);
else
ret->content = xmlStrndup(content, ret->length);
ret->content = xmlStrndup(content, ret->length);
} else {
ret->length = 0;
ret->content = NULL;
......
......@@ -15,9 +15,13 @@
#define HAVE_STDINT_H
#endif
#if defined(_MSC_VER) && _MSC_VER < 1900
#if defined(_MSC_VER)
#if _MSC_VER < 1900
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#endif
#if _MSC_VER < 1500
#define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
#endif
#endif
#endif /* __LIBXML_WIN32_CONFIG__ */
......
......@@ -9604,7 +9604,8 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
/*
* Attributes (xmlAttr).
*/
clone = (xmlNodePtr) xmlMalloc(sizeof(xmlAttr));
/* Use xmlRealloc to avoid -Warray-bounds warning */
clone = (xmlNodePtr) xmlRealloc(NULL, sizeof(xmlAttr));
if (clone == NULL) {
xmlTreeErrMemory("xmlDOMWrapCloneNode(): allocating an attr-node");
goto internal_error;
......
......@@ -10503,7 +10503,7 @@ xmlXPathCompFilterExpr(xmlXPathParserContextPtr ctxt) {
static xmlChar *
xmlXPathScanName(xmlXPathParserContextPtr ctxt) {
int len = 0, l;
int l;
int c;
const xmlChar *cur;
xmlChar *ret;
......@@ -10523,7 +10523,6 @@ xmlXPathScanName(xmlXPathParserContextPtr ctxt) {
(c == '_') || (c == ':') ||
(IS_COMBINING(c)) ||
(IS_EXTENDER(c)))) {
len += l;
NEXTL(l);
c = CUR_CHAR(l);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment