xref: /PHP-5.3/ext/dom/tests/bug45251.phpt (revision 790f5ee0)
1--TEST--
2Bug #45251 (double free or corruption with setAttributeNode())
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
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