php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29409 PHP segfaults when domDocument::documentElement return as variable
Submitted: 2004-07-27 17:07 UTC Modified: 2004-07-28 14:44 UTC
From: davey@php.net Assigned:
Status: Closed Package: XSLT related
PHP Version: 5.0.0 OS: WinXP w/SP1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: davey@php.net
New email:
PHP Version: OS:

 

 [2004-07-27 17:07 UTC] davey@php.net
Description:
------------
When you assign a the DomDocument::documentElement to a variable before returning it from a function called by the XSL extension, PHP segfaults.

See code for better explanation.

- Davey

Reproduce code:
---------------
<?php
$xsl = <<<XSL
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:php="http://php.net/xsl" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:crtx="http://synapticmedia.net/xmlns/crtx/template">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes" />
	<xsl:strip-space elements="*"/>
	<xsl:template match="/">
        <xsl:copy-of select="php:function('returnDomElement')" />
    </xsl:template>
</xsl:stylesheet>
XSL;
$xml = <<<XML
<root></root>
XML;
function returnDomElement() {
    $xml = '<root><child>cdata</child></root>';
    $dom = domDocument::loadXML($xml);
    /* change to 'return $dom->documentElement' and it works */
    $return = $dom->documentElement;
    return $return
}
$xsl = domDocument::loadXML($xsl);
$xml = domDocument::loadXML($xml);
$xp = new xsltProcessor;
$xp->registerPhpFunctions();
$xp->importStylesheet($xsl);
echo $xp->transformToXML($xml);
?>

Expected result:
----------------
<root>
  <child>cdata</child>
</root>


Actual result:
--------------
</> in the output and a segfault (details will be added by chregu)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-28 09:12 UTC] chregu@php.net
Fix is on the way
 [2004-07-28 14:44 UTC] chregu@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 15:01:30 2024 UTC