xref: /PHP-8.4/ext/libxml/tests/bug42112.phpt (revision 74859783)
1--TEST--
2Bug #42112 (deleting a node produces memory corruption)
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7$xml = <<<EOXML
8<root><child xml:id="id1">baz</child></root>
9EOXML;
10
11function remove_node($doc) {
12    $node = $doc->getElementById( 'id1' );
13    print 'Deleting Node: '.$node->nodeName."\n";
14    $node->parentNode->removeChild( $node );
15}
16
17$doc = new DOMDocument();
18$doc->loadXML($xml);
19
20remove_node($doc);
21
22$node = $doc->getElementById( 'id1' );
23if ($node) {
24    print 'Found Node: '.$node->nodeName."\n";
25}
26$root = $doc->documentElement;
27print 'Root Node: '.$root->nodeName."\n";
28?>
29--EXPECT--
30Deleting Node: child
31Root Node: root
32