mirror of
https://github.com/php/php-src.git
synced 2026-04-17 21:11:02 +02:00
When we decrement the refcount of a node's document, we state that we won't need it anymore. Therefore we can *always* set the pointer to the document to NULL, what avoids invalid memory accesses for some edge cases as demonstrated with the PHPT. Original patch provided by Sean Heelan.
20 lines
476 B
PHP
20 lines
476 B
PHP
--TEST--
|
|
Bug #66502 (DOM document dangling reference)
|
|
--SKIPIF--
|
|
<?php
|
|
if (!extension_loaded('dom')) die('skip requires ext/dom');
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
$dom = new DOMDocument('1.0', 'UTF-8');
|
|
$element = $dom->appendChild(new DOMElement('root'));
|
|
$comment = new DOMComment("Comment 0");
|
|
$comment = $element->appendChild($comment);
|
|
|
|
$comment->__construct("Comment 1");
|
|
$comment->__construct("Comment 2");
|
|
$comment->__construct("Comment 3");
|
|
echo 'DONE', PHP_EOL;
|
|
?>
|
|
--EXPECT--
|
|
DONE
|