Skip to content

SimpleXML's unset can break DOM objects #17040

Closed
@YuanchengJiang

Description

@YuanchengJiang

Description

The following code:

<?php
$dom = Dom\HTMLDocument::createEmpty();
$body = $dom->appendChild($dom->createElement("body"));
foreach (["style", "script", "xmp", "iframe", "noembed", "noframes", "plaintext", "noscript"] as $tag) {
$tag = $body->appendChild($dom->createElementNS("some:ns", $tag));
}
$fusion = $tag;
$html = simplexml_import_dom($fusion);
$script1_dataflow = $html;
$array = ['foo'];
foreach ($array as $key => &$value) {
unset($script1_dataflow[$key]);
}
var_dump(get_defined_vars());

Resulted in this output:

/php-src/ext/dom/token_list.c:206:25: runtime error: member access within null pointer of type 'php_libxml_ref_obj' (aka 'struct _php_libxml_ref_obj')

PHP Version

nightly

Operating System

ubuntu 22.04

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions