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
 [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-2019 The PHP Group
All rights reserved.
Last updated: Sat Jul 20 16:01:26 2019 UTC