From 51747d64baa0154da07802a519da0e6bcf9086a9 Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Fri, 26 Nov 2021 08:37:47 -0500 Subject: [PATCH] fix segfault on bad xml --- dom.d | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dom.d b/dom.d index baf08f8..a693f4b 100644 --- a/dom.d +++ b/dom.d @@ -1133,7 +1133,8 @@ class Document : FileResource, DomParent { } while (r.type != 0 || r.element.nodeType != 1); // we look past the xml prologue and doctype; root only begins on a regular node root = r.element; - root.parent_ = this; + if(root !is null) + root.parent_ = this; if(!strict) // in strict mode, we'll just ignore stuff after the xml while(r.type != 4) { @@ -8012,6 +8013,10 @@ unittest { } +unittest { + auto document = new Document("broken"); // just ensuring it doesn't crash +} + /* Copyright: Adam D. Ruppe, 2010 - 2021 License: Boost License 1.0.