]> granicus.if.org Git - php/commitdiff
Fix another memory leak in dom_zvals_to_fragment.
authorBenjamin Eberlei <kontakt@beberlei.de>
Thu, 5 Mar 2020 23:03:13 +0000 (00:03 +0100)
committerBenjamin Eberlei <kontakt@beberlei.de>
Thu, 5 Mar 2020 23:03:13 +0000 (00:03 +0100)
ext/dom/parentnode.c
ext/dom/tests/DOM4_ParentNode_append_with_attributes.phpt

index be30c79261142b597b414b76d5d1eac4ee0952ae..a9502a51590ca7f76bba74553e80d6cd6cca6db4 100644 (file)
@@ -179,6 +179,13 @@ xmlNode* dom_zvals_to_fragment(php_libxml_ref_obj *document, xmlNode *contextNod
                                newNodeObj->document = document;
                                xmlSetTreeDoc(newNode, documentNode);
 
+                               if (newNode->type == XML_ATTRIBUTE_NODE) {
+                                       xmlFree(fragment);
+
+                                       php_dom_throw_error(HIERARCHY_REQUEST_ERR, stricterror);
+                                       return NULL;
+                               }
+
                                if (!xmlAddChild(fragment, newNode)) {
                                        xmlFree(fragment);
 
index 3fb266729a89536f71f85fa7d60b4ff6b2a0fa78..f2c6aa9a6d1bd1ba3763998dbb769ea94522b97a 100644 (file)
@@ -19,8 +19,12 @@ $element = $dom->documentElement;
 try {
     $element->append($replacement, $addition);
 } catch (DOMException $e) {
-    echo $e->getMessage();
+    echo $e->getMessage() . "\n";
 }
+
+echo $dom->saveXML();
 ?>
 --EXPECT--
 Hierarchy Request Error
+<?xml version="1.0"?>
+<test attr-one="21"/>