php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47644 json_decode() fails to decode large int inside an array
Submitted: 2009-03-13 13:25 UTC Modified: 2009-03-17 02:04 UTC
From: asari at users dot sourceforge dot net Assigned:
Status: Closed Package: JSON related
PHP Version: 5.*, 6CVS (2009-03-15) OS: * (64bit)
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: asari at users dot sourceforge dot net
New email:
PHP Version: OS:

 

 [2009-03-13 13:25 UTC] asari at users dot sourceforge dot net
Description:
------------
In some cases, json_decode() fails to decode large integer (over 10000000000000000) inside an array, e.g. "[10000000000000001]".

$ uname -a
Linux _HOSTNAME_.localdomain 2.6.18-53.1.21.el5 #1 SMP Tue May 20 09:35:07 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release -a
LSB Version:    :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: CentOS
Description:    CentOS release 5.2 (Final)
Release:   5.2
Codename:  Final

$ ./sapi/cli/php --version
PHP 5.3.0beta2-dev (cli) (built: Mar 13 2009 21:55:38)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies

$ cat config.nice
#! /bin/sh
#
# Created by configure

'./configure' \
'--prefix=/tmp/php53' \
"$@"

Reproduce code:
---------------
$ for ((i=10000000000000000; i<10000000000000006; i++)); do echo $i; ./sapi/cli/php -r 'var_dump(json_decode("['$i']"));'; echo; done

Expected result:
----------------
10000000000000000
array(1) {
  [0]=>
  int(10000000000000000)
}

10000000000000001
array(1) {
  [0]=>
  int(10000000000000001)
}

10000000000000002
array(1) {
  [0]=>
  int(10000000000000002)
}

10000000000000003
array(1) {
  [0]=>
  int(10000000000000003)
}

10000000000000004
array(1) {
  [0]=>
  int(10000000000000004)
}

10000000000000005
array(1) {
  [0]=>
  int(10000000000000005)
}



Actual result:
--------------
10000000000000000
array(1) {
  [0]=>
  int(10000000000000000)
}

10000000000000001
array(1) {
  [0]=>
  int(10000000000000000)
}

10000000000000002
array(1) {
  [0]=>
  int(10000000000000002)
}

10000000000000003
array(1) {
  [0]=>
  int(10000000000000004)
}

10000000000000004
array(1) {
  [0]=>
  int(10000000000000004)
}

10000000000000005
array(1) {
  [0]=>
  int(10000000000000004)
}



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-17 02:04 UTC] scottmac@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Feb 03 06:01:30 2025 UTC