From 73af2f8d02cfba1bf910d96bf955b1d6ce510a86 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 19 Oct 2019 21:20:42 +0200 Subject: [PATCH] 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. --- Libraries/LibHTML/DOM/Document.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/LibHTML/DOM/Document.cpp b/Libraries/LibHTML/DOM/Document.cpp index ad2a552cfd..4856a71739 100644 --- a/Libraries/LibHTML/DOM/Document.cpp +++ b/Libraries/LibHTML/DOM/Document.cpp @@ -57,7 +57,7 @@ bool Document::is_child_allowed(const Node& node) const void Document::fixup() { - if (!is(first_child())) + if (!first_child() || !is(*first_child())) prepend_child(adopt(*new DocumentType(*this))); if (is(first_child()->next_sibling()))