From 9f28e21bb1d8251229fd4f951ddc280c7dbea597 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Wed, 13 Jun 2007 17:07:58 +0000 Subject: Fixed bug #41673 (json_encode breaks large numbers in arrays). --- ext/json/JSON_parser.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'ext/json/JSON_parser.c') diff --git a/ext/json/JSON_parser.c b/ext/json/JSON_parser.c index 2f2d268125..9f46553f67 100644 --- a/ext/json/JSON_parser.c +++ b/ext/json/JSON_parser.c @@ -284,7 +284,12 @@ static void json_create_zval(zval **z, smart_str *buf, int type) 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) { -- cgit v1.2.1