php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64917 Infinite loop when using SimpleXMLElement::attributes
Submitted: 2013-05-24 13:11 UTC Modified: 2015-09-04 14:32 UTC
From: nabice at gmail dot com Assigned: cmb (profile)
Status: Duplicate Package: SimpleXML related
PHP Version: 5.4.15 OS: Linux 3.8.0
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: nabice at gmail dot com
New email:
PHP Version: OS:

 

 [2013-05-24 13:11 UTC] nabice at gmail dot com
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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-04 14:32 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2015-09-04 14:32 UTC] cmb@php.net
This is a duplicate of bug #55098.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 22:01:29 2024 UTC