diff options
Diffstat (limited to 'ext/json/JSON_parser.c')
-rw-r--r-- | ext/json/JSON_parser.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/ext/json/JSON_parser.c b/ext/json/JSON_parser.c index 2f2d26812..c054d5038 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 || d < -LONG_MAX) { + ZVAL_DOUBLE(*z, d); + } else { + ZVAL_LONG(*z, (long)d); + } } else if (type == IS_DOUBLE) { |