xref: /PHP-8.4/ext/dom/tests/gh16777_1.phpt (revision 18b18f0e)
1--TEST--
2GH-16777 (Calling the constructor again on a DOM object after it is in a document causes UAF)
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7$text = new DOMText('my value');
8$doc = new DOMDocument();
9$doc->appendChild($text);
10$text->__construct('my new value');
11$doc->appendChild($text);
12echo $doc->saveXML();
13$dom2 = new DOMDocument();
14try {
15    $dom2->appendChild($text);
16} catch (DOMException $e) {
17    echo $e->getMessage(), "\n";
18}
19?>
20--EXPECT--
21<?xml version="1.0"?>
22my value
23my new value
24Wrong Document Error
25