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
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: chad at herballure dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 10:01:29 2025 UTC