summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugh Davenport <hugh@davenport.net.nz>2016-05-04 10:55:49 +0800
committerDaniel Veillard <veillard@redhat.com>2016-05-04 10:55:49 +0800
commitb8e0fa3489b344d9cbd1165687e7dc5b15cc3727 (patch)
tree68c15d181eb7cbf84f79af09703d74c3906272ae
parent90da33cebeba87ae3b49a270c8182142dd7cb48e (diff)
downloadlibxml2-b8e0fa3489b344d9cbd1165687e7dc5b15cc3727.tar.gz
Fix null pointer deref in docs with no root element
From https://bugzilla.gnome.org/show_bug.cgi?id=758514
-rw-r--r--xmllint.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/xmllint.c b/xmllint.c
index 9e85c11b..00f1769f 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -2002,6 +2002,12 @@ static void walkDoc(xmlDocPtr doc) {
xmlNsPtr ns;
root = xmlDocGetRootElement(doc);
+ if (root == NULL ) {
+ xmlGenericError(xmlGenericErrorContext,
+ "Document does not have a root element");
+ progresult = XMLLINT_ERR_UNCLASS;
+ return;
+ }
for (ns = root->nsDef, i = 0;ns != NULL && i < 20;ns=ns->next) {
namespaces[i++] = ns->href;
namespaces[i++] = ns->prefix;