iliaa Wed Jun 13 17:07:59 2007 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/json json.c JSON_parser.c
/php-src/ext/json/tests pass001.1.phpt
/php-src NEWS
Log:
Fixed bug #41673 (json_encode breaks large numbers in arrays).
http://cvs.php.net/viewvc.cgi/php-src/ext/json/json.c?r1=1.9.2.16&r2=1.9.2.17&diff_format=u
Index: php-src/ext/json/json.c
diff -u php-src/ext/json/json.c:1.9.2.16 php-src/ext/json/json.c:1.9.2.17
--- php-src/ext/json/json.c:1.9.2.16 Mon Jun 4 23:51:32 2007
+++ php-src/ext/json/json.c Wed Jun 13 17:07:58 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: json.c,v 1.9.2.16 2007/06/04 23:51:32 iliaa Exp $ */
+/* $Id: json.c,v 1.9.2.17 2007/06/13 17:07:58 iliaa Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -355,17 +355,9 @@
if (!zend_isinf(dbl) && !zend_isnan(dbl)) {
len = spprintf(&d, 0, "%.*g", (int) EG(precision), dbl);
- if (d) {
- if (dbl > LONG_MAX && !memchr(d, '.', len)) {
- smart_str_append_unsigned(buf,
(unsigned long)Z_DVAL_P(val));
- } else {
- smart_str_appendl(buf, d, len);
- }
- efree(d);
- }
- }
- else
- {
+ smart_str_appendl(buf, d, len);
+ efree(d);
+ } else {
zend_error(E_WARNING, "[json] (json_encode_r) double %.9g
does not conform to the JSON spec, encoded as 0.", dbl);
smart_str_appendc(buf, '0');
}
http://cvs.php.net/viewvc.cgi/php-src/ext/json/JSON_parser.c?r1=1.1.2.10&r2=1.1.2.11&diff_format=u
Index: php-src/ext/json/JSON_parser.c
diff -u php-src/ext/json/JSON_parser.c:1.1.2.10
php-src/ext/json/JSON_parser.c:1.1.2.11
--- php-src/ext/json/JSON_parser.c:1.1.2.10 Sun May 27 16:31:35 2007
+++ php-src/ext/json/JSON_parser.c Wed Jun 13 17:07:58 2007
@@ -284,7 +284,12 @@
if (type == IS_LONG)
{
- ZVAL_LONG(*z, atol(buf->c));
+ double d = zend_strtod(buf->c, NULL);
+ if (d > LONG_MAX) {
+ ZVAL_DOUBLE(*z, d);
+ } else {
+ ZVAL_LONG(*z, (long)d);
+ }
}
else if (type == IS_DOUBLE)
{
http://cvs.php.net/viewvc.cgi/php-src/ext/json/tests/pass001.1.phpt?r1=1.3.2.7&r2=1.3.2.8&diff_format=u
Index: php-src/ext/json/tests/pass001.1.phpt
diff -u php-src/ext/json/tests/pass001.1.phpt:1.3.2.7
php-src/ext/json/tests/pass001.1.phpt:1.3.2.8
--- php-src/ext/json/tests/pass001.1.phpt:1.3.2.7 Mon Jun 11 15:07:40 2007
+++ php-src/ext/json/tests/pass001.1.phpt Wed Jun 13 17:07:58 2007
@@ -569,7 +569,7 @@
["_empty_"]=>
int(0)
["E no ."]=>
- int(4000000000000)
+ %s(4000000000000)
["zero"]=>
int(0)
["one"]=>
@@ -748,7 +748,7 @@
[""]=>
int(0)
["E no ."]=>
- int(4000000000000)
+ %s(4000000000000)
["zero"]=>
int(0)
["one"]=>
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.777&r2=1.2027.2.547.2.778&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.777 php-src/NEWS:1.2027.2.547.2.778
--- php-src/NEWS:1.2027.2.547.2.777 Wed Jun 13 16:48:10 2007
+++ php-src/NEWS Wed Jun 13 17:07:58 2007
@@ -89,6 +89,7 @@
- Fixed altering $this via argument named "this". (Dmitry)
- Fixed PHP CLI usage of php.ini from the binary location. (Hannes)
- Fixed segfault in strripos(). (Tony, Joxean Koret)
+- Fixed bug #41673 (json_encode breaks large numbers in arrays). (Ilia)
- Fixed bug #41525 (ReflectionParameter::getPosition() not available). (Marcus)
- Fixed bug #41511 (Compile failure under IRIX 6.5.30 building md5.c). (Jani)
- Fixed bug #41504 (json_decode() incorrectly decodes JSON arrays with empty
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php