1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/xsl/tests/gh19988.phpt
Niels Dossche d94846c3b4 Fix GH-19988: zend_string_init with NULL pointer in simplexml (UB)
Normally, simplexml cannot import document nodes,
but xsl allows to circumvent this.
A document does not have a name, so we return the empty string
in that case.
While we could add an explicit check, we might as well switch
the macro to a form that would be more optimal anyway as many
tag names can be single characters.

The test was added in xsl because adding it in simplexml would
break out-of-tree builds of simplexml.

Closes GH-19990.
2025-09-29 16:07:34 +02:00

20 lines
472 B
PHP

--TEST--
GH-19988 (zend_string_init with NULL pointer in simplexml (UB))
--EXTENSIONS--
simplexml
xsl
--CREDITS--
YuanchengJiang
--FILE--
<?php
$sxe = simplexml_load_file(__DIR__ . '/53965/collection.xml');
$processor = new XSLTProcessor;
$dom = new DOMDocument;
$dom->load(__DIR__ . '/53965/collection.xsl');
$processor->importStylesheet($dom);
$result = $processor->transformToDoc($sxe, SimpleXMLElement::class);
var_dump($result->getName());
?>
--EXPECT--
string(0) ""