summaryrefslogtreecommitdiff
path: root/ext/json/JSON_parser.c
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2007-06-13 17:07:58 +0000
committerIlia Alshanetsky <iliaa@php.net>2007-06-13 17:07:58 +0000
commit9f28e21bb1d8251229fd4f951ddc280c7dbea597 (patch)
tree490de1f31191a743126a937d1750cf249a13a574 /ext/json/JSON_parser.c
parent1c7fa8fb4c3c1fb4bcd42a8421c29a1753e5d4bc (diff)
downloadphp-git-9f28e21bb1d8251229fd4f951ddc280c7dbea597.tar.gz
Fixed bug #41673 (json_encode breaks large numbers in arrays).
Diffstat (limited to 'ext/json/JSON_parser.c')
-rw-r--r--ext/json/JSON_parser.c7
1 files changed, 6 insertions, 1 deletions
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)
{