xref: /PHP-8.3/ext/dom/tests/bug45251.phpt (revision bd9f4fa6)
1--TEST--
2Bug #45251 (double free or corruption with setAttributeNode())
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7$doc = new DOMDocument;
8$doc->loadXml(<<<EOF
9<?xml version="1.0" encoding="utf-8" ?>
10<aaa>
11  <bbb foo="bar"/>
12</aaa>
13EOF
14);
15
16$xpath = new DOMXPath($doc);
17
18$bbb = $xpath->query('bbb', $doc->documentElement)->item(0);
19
20$ccc = $doc->createElement('ccc');
21foreach ($bbb->attributes as $attr)
22{
23  $ccc->setAttributeNode($attr);
24}
25
26echo $attr->parentNode->localName;
27
28?>
29--EXPECT--
30ccc
31