php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57397 Infinite loop encoding circular structures
Submitted: 2006-11-27 16:02 UTC Modified: 2008-12-18 21:28 UTC
From: chad at herballure dot com Assigned:
Status: Closed Package: json (PECL)
PHP Version: 5.1.6 OS: SuSE 9.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
43 - 32 = ?
Subscribe to this entry?

 
 [2006-11-27 16:02 UTC] chad at herballure dot com
Description:
------------
When asked to encode a circular data structure, json_encode does not notice.

Reproduce code:
---------------
<?php
$data = array('a' => 12);
$data['bad'] =& $data;
var_dump(json_encode($data));
?>

Expected result:
----------------
Some sort of error about object recursion, as this is not supported by JSON.

Actual result:
--------------
PHP Fatal error:  Allowed memory size of 25165824 bytes exhausted (tried to allocate 128 bytes) ...

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-29 11:47 UTC] chad at herballure dot com
Further research reveals this was fixed 4 months ago in CVS and for MAIN and PHP_5_2. Can we get a fresh PECL release?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 06:01:32 2024 UTC