Bladeren bron

LibHTML: DOM fixup should handle a completely empty document

We were forgetting to check if there was even a first child of the
root Document node.
Andreas Kling 5 jaren geleden
bovenliggende
commit
73af2f8d02
1 gewijzigde bestanden met toevoegingen van 1 en 1 verwijderingen
  1. 1 1
      Libraries/LibHTML/DOM/Document.cpp

+ 1 - 1
Libraries/LibHTML/DOM/Document.cpp

@@ -57,7 +57,7 @@ bool Document::is_child_allowed(const Node& node) const
 
 void Document::fixup()
 {
-    if (!is<DocumentType>(first_child()))
+    if (!first_child() || !is<DocumentType>(*first_child()))
         prepend_child(adopt(*new DocumentType(*this)));
 
     if (is<HTMLHtmlElement>(first_child()->next_sibling()))