From:             nabice at gmail dot com
Operating system: Linux 3.8.0
PHP version:      5.4.15
Package:          SimpleXML related
Bug Type:         Bug
Bug description:Infinite loop when using SimpleXMLElement::attributes

Description:
------------
When I use SimpleXML to find some element's attributes, A mistake leads to

infinite loop.

I was meaning "$child->atttibutes()", but "$childs->attributes()" by
mistake, 
then some strange things happen: Infinite loop.

Is it a bug?

Test script:
---------------
<?php
$xml = simplexml_load_string('<root><parent><child id="1"/><child
id="2"/></parent></root>');
$childs = $xml->parent->child;
foreach($childs as $child){
        var_dump($childs->attributes());
}
?>

Expected result:
----------------
Print:

object(SimpleXMLElement)#6 (1) {
  ["@attributes"]=>
  array(1) {
    ["id"]=>
    string(1) "1"
  }
}
object(SimpleXMLElement)#6 (1) {
  ["@attributes"]=>
  array(1) {
    ["id"]=>
    string(1) "1"
  }
}

Actual result:
--------------
Infinite loop.

-- 
Edit bug report at https://bugs.php.net/bug.php?id=64918&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=64918&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=64918&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=64918&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=64918&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=64918&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=64918&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=64918&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=64918&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=64918&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=64918&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=64918&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=64918&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=64918&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64918&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=64918&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=64918&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=64918&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64918&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=64918&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=64918&r=mysqlcfg

Reply via email to