From 8d526514f23939cf028646307506daa1a01202fd Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sat, 20 Jul 2024 19:53:36 +0200 Subject: [PATCH] Remove bogus tree setting code from parentnode/tree.c I don't know why this code was here in the first place, it is present since the initial implementation. It doesn't make sense because: 1. It would require updating the refcounts if the document wasn't actually already set. 2. We enforce that the document is the same as the target document by this point, so setting the tree is pointless. --- ext/dom/parentnode/tree.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ext/dom/parentnode/tree.c b/ext/dom/parentnode/tree.c index f16f4ad3c7f95..97fd3fa9a6e55 100644 --- a/ext/dom/parentnode/tree.c +++ b/ext/dom/parentnode/tree.c @@ -377,8 +377,7 @@ xmlNode* dom_zvals_to_single_node(php_libxml_ref_obj *document, xmlNode *context xmlUnlinkNode(newNode); } - newNodeObj->document = document; - xmlSetTreeDoc(newNode, documentNode); + ZEND_ASSERT(newNodeObj->document == document); if (newNode->type == XML_DOCUMENT_FRAG_NODE) { /* Unpack document fragment nodes, the behaviour differs for different libxml2 versions. */