Skip to content

Segmentation fault with $outerHTML and next node #16356

Closed
@YuanchengJiang

Description

@YuanchengJiang

Description

The following code:

<?php
function test($vars) {}
class_alias('foo', 'baz');
$dom = Dom\HTMLDocument::createEmpty();
$dom->append($dom->createElement("container"));
$e1 = $dom->documentElement->appendChild($dom->createElementNS("urn:example1", "example:foo"));
$e2 = $dom->documentElement->appendChild($dom->createElementNS("urn:example2", "example:foo"));
$v3=$definedVars[array_rand($definedVars = get_defined_vars())];
var_dump('random_var:',$v1,$v2,$v3);

Resulted in this output:

/php-src/ext/dom/html5_serializer.c:341:15: runtime error: member access within null pointer of type 'const xmlNode' (aka 'const struct _xmlNode')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /php-src/ext/dom/html5_serializer.c:341:15

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