xmllint: Fix --insert option
Make sure that parent is an element when calling
xmlValidGetValidElements.
diff --git a/xmllint.c b/xmllint.c
index 1451b5e..d740b76 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -2492,7 +2492,10 @@
if (doc->children != NULL) {
node = doc->children;
- while ((node != NULL) && (node->last == NULL)) node = node->next;
+ while ((node != NULL) &&
+ ((node->type != XML_ELEMENT_NODE) ||
+ (node->last == NULL)))
+ node = node->next;
if (node != NULL) {
nb = xmlValidGetValidElements(node->last, NULL, list, 256);
if (nb < 0) {