diff options
Diffstat (limited to 'chromium/third_party/libxml/src/SAX2.c')
-rw-r--r-- | chromium/third_party/libxml/src/SAX2.c | 72 |
1 files changed, 43 insertions, 29 deletions
diff --git a/chromium/third_party/libxml/src/SAX2.c b/chromium/third_party/libxml/src/SAX2.c index 3d75751e4be..b3dd89b164f 100644 --- a/chromium/third_party/libxml/src/SAX2.c +++ b/chromium/third_party/libxml/src/SAX2.c @@ -387,6 +387,9 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name, xmlCharEncoding enc; int oldcharset; const xmlChar *oldencoding; + int oldprogressive; + unsigned long consumed; + size_t buffered; /* * Ask the Entity resolver to load the damn thing @@ -409,18 +412,22 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name, oldinputTab = ctxt->inputTab; oldcharset = ctxt->charset; oldencoding = ctxt->encoding; + oldprogressive = ctxt->progressive; ctxt->encoding = NULL; + ctxt->progressive = 0; ctxt->inputTab = (xmlParserInputPtr *) xmlMalloc(5 * sizeof(xmlParserInputPtr)); if (ctxt->inputTab == NULL) { xmlSAX2ErrMemory(ctxt, "xmlSAX2ExternalSubset"); + xmlFreeInputStream(input); ctxt->input = oldinput; ctxt->inputNr = oldinputNr; ctxt->inputMax = oldinputMax; ctxt->inputTab = oldinputTab; ctxt->charset = oldcharset; ctxt->encoding = oldencoding; + ctxt->progressive = oldprogressive; return; } ctxt->inputNr = 0; @@ -455,6 +462,18 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name, while (ctxt->inputNr > 1) xmlPopInput(ctxt); + + consumed = ctxt->input->consumed; + buffered = ctxt->input->cur - ctxt->input->base; + if (buffered > ULONG_MAX - consumed) + consumed = ULONG_MAX; + else + consumed += buffered; + if (consumed > ULONG_MAX - ctxt->sizeentities) + ctxt->sizeentities = ULONG_MAX; + else + ctxt->sizeentities += consumed; + xmlFreeInputStream(ctxt->input); xmlFree(ctxt->inputTab); @@ -471,6 +490,7 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name, (!xmlDictOwns(ctxt->dict, ctxt->encoding)))) xmlFree((xmlChar *) ctxt->encoding); ctxt->encoding = oldencoding; + ctxt->progressive = oldprogressive; /* ctxt->wellFormed = oldwellFormed; */ } } @@ -1315,25 +1335,25 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname, /* !!!!!! <a toto:arg="" xmlns:toto="http://toto.com"> */ ret = xmlNewNsPropEatName(ctxt->node, namespace, name, NULL); + if (ret == NULL) + goto error; - if (ret != NULL) { - if ((ctxt->replaceEntities == 0) && (!ctxt->html)) { - xmlNodePtr tmp; - - ret->children = xmlStringGetNodeList(ctxt->myDoc, value); - tmp = ret->children; - while (tmp != NULL) { - tmp->parent = (xmlNodePtr) ret; - if (tmp->next == NULL) - ret->last = tmp; - tmp = tmp->next; - } - } else if (value != NULL) { - ret->children = xmlNewDocText(ctxt->myDoc, value); - ret->last = ret->children; - if (ret->children != NULL) - ret->children->parent = (xmlNodePtr) ret; - } + if ((ctxt->replaceEntities == 0) && (!ctxt->html)) { + xmlNodePtr tmp; + + ret->children = xmlStringGetNodeList(ctxt->myDoc, value); + tmp = ret->children; + while (tmp != NULL) { + tmp->parent = (xmlNodePtr) ret; + if (tmp->next == NULL) + ret->last = tmp; + tmp = tmp->next; + } + } else if (value != NULL) { + ret->children = xmlNewDocText(ctxt->myDoc, value); + ret->last = ret->children; + if (ret->children != NULL) + ret->children->parent = (xmlNodePtr) ret; } #ifdef LIBXML_VALID_ENABLED @@ -2264,6 +2284,7 @@ xmlSAX2StartElementNs(void *ctx, ret->name = lname; if (ret->name == NULL) { xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs"); + xmlFree(ret); return; } } @@ -2635,7 +2656,8 @@ xmlSAX2Text(xmlParserCtxtPtr ctxt, const xmlChar *ch, int len, /* Mixed content, first time */ if (type == XML_TEXT_NODE) { lastChild = xmlSAX2TextNode(ctxt, ch, len); - lastChild->doc = ctxt->myDoc; + if (lastChild != NULL) + lastChild->doc = ctxt->myDoc; } else lastChild = xmlNewCDataBlock(ctxt->myDoc, ch, len); if (lastChild != NULL) { @@ -2931,7 +2953,7 @@ xmlSAX2InitDefaultSAXHandler(xmlSAXHandler *hdlr, int warning) /** * xmlDefaultSAXHandlerInit: * - * DEPRECATED: This function will be made private. Call xmlInitParser to + * DEPRECATED: This function is a no-op. Call xmlInitParser to * initialize the library. * * Initialize the default SAX2 handler @@ -2939,9 +2961,6 @@ xmlSAX2InitDefaultSAXHandler(xmlSAXHandler *hdlr, int warning) void xmlDefaultSAXHandlerInit(void) { -#ifdef LIBXML_SAX1_ENABLED - xmlSAXVersion((xmlSAXHandlerPtr) &xmlDefaultSAXHandler, 1); -#endif /* LIBXML_SAX1_ENABLED */ } #ifdef LIBXML_HTML_ENABLED @@ -2992,17 +3011,12 @@ xmlSAX2InitHtmlDefaultSAXHandler(xmlSAXHandler *hdlr) /** * htmlDefaultSAXHandlerInit: * - * DEPRECATED: This function will be made private. Call xmlInitParser to + * DEPRECATED: This function is a no-op. Call xmlInitParser to * initialize the library. - * - * Initialize the default SAX handler */ void htmlDefaultSAXHandlerInit(void) { -#ifdef LIBXML_SAX1_ENABLED - xmlSAX2InitHtmlDefaultSAXHandler((xmlSAXHandlerPtr) &htmlDefaultSAXHandler); -#endif } #endif /* LIBXML_HTML_ENABLED */ |