summaryrefslogtreecommitdiff
path: root/SAX2.c
diff options
context:
space:
mode:
authorAron Xu <aron@debian.org>2015-09-21 22:58:06 +0800
committerAron Xu <aron@debian.org>2015-09-21 22:58:06 +0800
commit2ee13d9e464a1f5daccaff58f5d09d36b7c4f667 (patch)
treeb022967f880b7fb1e56c8cc4c3f200d6ffbc9efd /SAX2.c
parent7300193becde71a344c8ac0973dc290fa24d800d (diff)
downloadlibxml2-2ee13d9e464a1f5daccaff58f5d09d36b7c4f667.tar.gz
Revert "Imported Upstream version 2.9.1+dfsg1"upstream
This reverts commit 7300193becde71a344c8ac0973dc290fa24d800d.
Diffstat (limited to 'SAX2.c')
-rw-r--r--SAX2.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/SAX2.c b/SAX2.c
index 4adf202..ffef3e1 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -994,12 +994,12 @@ xmlSAX2StartDocument(void *ctx)
#ifdef LIBXML_HTML_ENABLED
if (ctxt->myDoc == NULL)
ctxt->myDoc = htmlNewDocNoDtD(NULL, NULL);
- ctxt->myDoc->properties = XML_DOC_HTML;
- ctxt->myDoc->parseFlags = ctxt->options;
if (ctxt->myDoc == NULL) {
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartDocument");
return;
}
+ ctxt->myDoc->properties = XML_DOC_HTML;
+ ctxt->myDoc->parseFlags = ctxt->options;
#else
xmlGenericError(xmlGenericErrorContext,
"libxml2 built without HTML support\n");
@@ -1078,7 +1078,7 @@ xmlSAX2EndDocument(void *ctx)
}
}
-#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED)
+#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
/**
* xmlSAX2AttributeInternal:
* @ctx: the user data (XML parser context)
@@ -1177,6 +1177,12 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
val = xmlStringDecodeEntities(ctxt, value, XML_SUBSTITUTE_REF,
0,0,0);
ctxt->depth--;
+ if (val == NULL) {
+ xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement");
+ if (name != NULL)
+ xmlFree(name);
+ return;
+ }
} else {
val = (xmlChar *) value;
}
@@ -1822,7 +1828,7 @@ xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRIBUTE_UNUSED)
#endif
nodePop(ctxt);
}
-#endif /* LIBXML_SAX1_ENABLED || LIBXML_HTML_ENABLE */
+#endif /* LIBXML_SAX1_ENABLED || LIBXML_HTML_ENABLED || LIBXML_LEGACY_ENABLED */
/*
* xmlSAX2TextNode:
@@ -2145,6 +2151,7 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
*/
if (dup == NULL)
dup = xmlStrndup(value, valueend - value);
+#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
#ifdef LIBXML_VALID_ENABLED
if (xmlValidateNCName(dup, 1) != 0) {
xmlErrValid(ctxt, XML_DTD_XMLID_VALUE,
@@ -2152,6 +2159,7 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
(const char *) dup, NULL);
}
#endif
+#endif
xmlAddID(&ctxt->vctxt, ctxt->myDoc, dup, ret);
} else if (xmlIsID(ctxt->myDoc, ctxt->node, ret)) {
/* might be worth duplicate entry points and not copy */
@@ -2570,6 +2578,10 @@ xmlSAX2Characters(void *ctx, const xmlChar *ch, int len)
(xmlDictOwns(ctxt->dict, lastChild->content))) {
lastChild->content = xmlStrdup(lastChild->content);
}
+ if (lastChild->content == NULL) {
+ xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters: xmlStrdup returned NULL");
+ return;
+ }
if (((size_t)ctxt->nodelen + (size_t)len > XML_MAX_TEXT_LENGTH) &&
((ctxt->options & XML_PARSE_HUGE) == 0)) {
xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters: huge text node");