48b6bc7
From 0815302dee2b78139832c2080348086a0564836b Mon Sep 17 00:00:00 2001
48b6bc7
From: Nick Wellnhofer <wellnhofer@aevum.de>
48b6bc7
Date: Fri, 6 Dec 2019 12:27:29 +0100
48b6bc7
Subject: [PATCH] Fix freeing of nested documents
48b6bc7
48b6bc7
Apparently, some libxslt RVTs can contain nested document nodes, see
48b6bc7
issue #132. I'm not sure how this happens exactly but it can cause a
48b6bc7
segfault in xmlFreeNodeList after the changes in commit 0762c9b6.
48b6bc7
48b6bc7
Make sure not to touch the (nonexistent) `content` member of xmlDocs.
48b6bc7
---
48b6bc7
 tree.c | 5 +++++
48b6bc7
 1 file changed, 5 insertions(+)
48b6bc7
48b6bc7
diff --git a/tree.c b/tree.c
48b6bc7
index 070670f1..0d7fc98c 100644
48b6bc7
--- a/tree.c
48b6bc7
+++ b/tree.c
48b6bc7
@@ -3708,6 +3708,11 @@ xmlFreeNodeList(xmlNodePtr cur) {
48b6bc7
 		(cur->type != XML_XINCLUDE_START) &&
48b6bc7
 		(cur->type != XML_XINCLUDE_END) &&
48b6bc7
 		(cur->type != XML_ENTITY_REF_NODE) &&
48b6bc7
+		(cur->type != XML_DOCUMENT_NODE) &&
48b6bc7
+#ifdef LIBXML_DOCB_ENABLED
48b6bc7
+		(cur->type != XML_DOCB_DOCUMENT_NODE) &&
48b6bc7
+#endif
48b6bc7
+		(cur->type != XML_HTML_DOCUMENT_NODE) &&
48b6bc7
 		(cur->content != (xmlChar *) &(cur->properties))) {
48b6bc7
 		DICT_FREE(cur->content)
48b6bc7
 	    }
48b6bc7
-- 
48b6bc7
2.22.0
48b6bc7