| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
  [2007-06-04 09:53 UTC] judas dot iscariote at gmail dot com
 Description:
------------
the following code segafaults.
Reproduce code:
---------------
<?php
$xml = new SimpleXMLElement('<?xml version="1.0" standalone="yes"?> <collection></collection>');
$xml->movie[]->characters->character[0]->name = 'Miss Coder';
//or crashes too ( same issue) 
//$xml->movie[0]->characters->character[]->name = 'Miss Coder';
var_dump($xml->asXml());
?>
Expected result:
----------------
Fatal Error: cannot use [] for reading.
Actual result:
--------------
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 47237115809024 (LWP 23360)]
0x000000000056e7d0 in sxe_prop_dim_read (object=0xc94dd8, member=0x0, elements=0 '\0', attribs=1 '\001', silent=0 '\0')
    at /home/cristian/php5/ext/simplexml/simplexml.c:254
254             if (Z_TYPE_P(member) == IS_LONG) {
....
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             | 
    |||||||||||||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 15:00:01 2025 UTC | 
fix works. but leaks memory in the above situation. $xml = new SimpleXMLElement('<?xml version="1.0" standalone="yes"?> <collection></collection>'); $xml->movie[1]->characters->character[]->name = 'Miss Coder'; Zend/zend_execute.c(1249) : Freeing 0x00C97DA0 (24 bytes), script=simplecrashes.php === Total 1 memory leaks detected ===