mirror of
https://github.com/php/php-src.git
synced 2024-11-24 18:34:21 +08:00
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #70078: XSL callbacks with nodes as parameter leak memory
This commit is contained in:
commit
dfbeee034a
3
NEWS
3
NEWS
@ -54,6 +54,9 @@ PHP NEWS
|
||||
. Fixed bug #78902 (Memory leak when using stream_filter_append). (liudaixiao)
|
||||
. Fixed bug #78969 (PASSWORD_DEFAULT should match PASSWORD_BCRYPT instead of being null). (kocsismate)
|
||||
|
||||
- XSL:
|
||||
. Fixed bug #70078 (XSL callbacks with nodes as parameter leak memory). (cmb)
|
||||
|
||||
- Zip:
|
||||
. Add ZipArchive::CM_LZMA2 and ZipArchive::CM_XZ constants (since libzip 1.6.0). (remi)
|
||||
. Add ZipArchive::ER_* missing constants. (remi)
|
||||
|
51
ext/xsl/tests/bug70078.phpt
Normal file
51
ext/xsl/tests/bug70078.phpt
Normal file
@ -0,0 +1,51 @@
|
||||
--TEST--
|
||||
Bug #70078 (XSL callbacks with nodes as parameter leak memory)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('xsl')) die('skip xsl extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
// create big dummy document:
|
||||
$dom = new \DOMDocument();
|
||||
$rootNode = $dom->appendChild($dom->createElement('root'));
|
||||
for ($i = 0; $i <= 100; $i++) {
|
||||
$level1Node = $rootNode->appendChild($dom->createElement('level1'));
|
||||
for ($j = 0; $j <= 100; $j++) {
|
||||
$level2Node = $level1Node->appendChild($dom->createElement('level2'));
|
||||
for ($k = 0; $k <= 10; $k++) {
|
||||
$level3Node = $level2Node->appendChild($dom->createElement('level3', 'test'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function testPhpFunction($node) {
|
||||
return 'test2';
|
||||
}
|
||||
|
||||
$xslStr = <<<EOF
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl">
|
||||
<xsl:template match="root">
|
||||
<output>
|
||||
<xsl:for-each select="level1">
|
||||
<node>
|
||||
<xsl:value-of select="php:function('testPhpFunction', .)" />
|
||||
</node>
|
||||
</xsl:for-each>
|
||||
</output>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
EOF;
|
||||
|
||||
$xsl = new \DOMDocument();
|
||||
$xsl->loadXML($xslStr);
|
||||
$xslt = new \XSLTProcessor();
|
||||
$xslt->registerPHPFunctions('testPhpFunction');
|
||||
$xslt->importStyleSheet($xsl);
|
||||
|
||||
echo $xslt->transformToXML($dom);
|
||||
?>
|
||||
--EXPECT--
|
||||
<?xml version="1.0"?>
|
||||
<output xmlns:php="http://php.net/xsl"><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node><node>test2</node></output>
|
@ -277,7 +277,7 @@ static void xsl_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int t
|
||||
node->parent = nsparent;
|
||||
node->ns = curns;
|
||||
} else {
|
||||
node = xmlDocCopyNodeList(domintern->document->ptr, node);
|
||||
node = xmlDocCopyNode(node, domintern->document->ptr, 1);
|
||||
}
|
||||
|
||||
php_dom_create_object(node, &child, domintern);
|
||||
|
Loading…
Reference in New Issue
Block a user