From: Scott MacVicar Date: Tue, 17 Mar 2009 14:57:39 +0000 (+0000) Subject: MFH Deal with overflow when decoding large numbers X-Git-Tag: php-5.3.0RC1~58 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3a0c86327f891a3d150bc8165d5ec86d09bc94a8;p=php MFH Deal with overflow when decoding large numbers --- diff --git a/ext/json/JSON_parser.c b/ext/json/JSON_parser.c index 8eaf65e85c..7125012610 100644 --- a/ext/json/JSON_parser.c +++ b/ext/json/JSON_parser.c @@ -290,8 +290,9 @@ static void json_create_zval(zval **z, smart_str *buf, int type) if (type == IS_LONG) { long l = strtol(buf->c, NULL, 10); - if (l > LONG_MAX || l < LONG_MIN) { - ZVAL_DOUBLE(*z, zend_strtod(buf->c, NULL)); + double d = zend_strtod(buf->c, NULL); + if (d > LONG_MAX || d < LONG_MIN) { + ZVAL_DOUBLE(*z, d); } else { ZVAL_LONG(*z, l); }