|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71900 json_decode warns of integer overflow for max int
Submitted: 2016-03-25 14:55 UTC Modified: 2016-04-03 04:22 UTC
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:1 (33.3%)
From: david at frankieandshadow dot com Assigned:
Status: No Feedback Package: Unknown/Other Function
PHP Version: 5.6.19 OS: Debian Jessie (64 bit)
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 — but make sure to vote on the bug!
Your email address:
Solve the problem:
16 + 26 = ?
Subscribe to this entry?

 [2016-03-25 14:55 UTC] david at frankieandshadow dot com
This is actually version 5.6.17, it is not practical for me to upgrade currently. 5.6.17 is the most up to date Debian Jessie distribution.

The json_decode function produces 
   PHP Notice:  json_decode(): integer overflow detected in .../test.php on line 11
when the value concerned is 9223372036854775807 (i.e. PHP_INT_MAX), which is a valid value.

This has a particular impact in decoding certain results from elasticsearch which contain max int values.

Test script:

echo PHP_INT_MAX, "\n";

$a = array('a' => PHP_INT_MAX); /* it works OK if you put PHP_INT_MAX-1 here */
$j = json_encode($a);

echo $j, "\n";

$b = json_decode($j); /* produces the incorrect error message */

Expected result:
No warning.

Actual result:
PHP Notice:  json_decode(): integer overflow detected


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-03-25 17:45 UTC]
-Status: Open +Status: Feedback
 [2016-03-25 17:45 UTC]

I am am unable to reproduce this error on any version of PHP that was released by the PHP team.

I think you need to open a ticket with the Debian maintainers of PHP. They replaced the json extension that PHP ships with, with one that had a different license.
 [2016-03-26 12:17 UTC] david at frankieandshadow dot com
Thank you. Reported to Debian as
 [2016-04-03 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 24 23:01:31 2024 UTC