iliaa Wed Jun 13 17:10:06 2007 UTC Modified files: /php-src/ext/json json.c JSON_parser.c Log: MFB: Fixed bug #41673 (json_encode breaks large numbers in arrays). http://cvs.php.net/viewvc.cgi/php-src/ext/json/json.c?r1=1.26&r2=1.27&diff_format=u Index: php-src/ext/json/json.c diff -u php-src/ext/json/json.c:1.26 php-src/ext/json/json.c:1.27 --- php-src/ext/json/json.c:1.26 Mon Jun 4 23:52:34 2007 +++ php-src/ext/json/json.c Wed Jun 13 17:10:06 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: json.c,v 1.26 2007/06/04 23:52:34 iliaa Exp $ */ +/* $Id: json.c,v 1.27 2007/06/13 17:10:06 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -363,15 +363,9 @@ double dbl = Z_DVAL_P(val); 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); - } + len = spprintf(&d, 0, "%.*g", (int) EG(precision), dbl); + 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.13&r2=1.14&diff_format=u Index: php-src/ext/json/JSON_parser.c diff -u php-src/ext/json/JSON_parser.c:1.13 php-src/ext/json/JSON_parser.c:1.14 --- php-src/ext/json/JSON_parser.c:1.13 Fri Jun 8 08:57:21 2007 +++ php-src/ext/json/JSON_parser.c Wed Jun 13 17:10:06 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) {
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php