Fix null pointer deref in docs with no root element
From https://bugzilla.gnome.org/show_bug.cgi?id=758514
diff --git a/xmllint.c b/xmllint.c
index 9e85c11..00f1769 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -2002,6 +2002,12 @@
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;