From: Scott MacVicar Date: Tue, 17 Mar 2009 14:56:49 +0000 (+0000) Subject: Deal with overflow when decoding large numbers X-Git-Tag: php-5.4.0alpha1~191^2~4127 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2d43af2707ee5549140f45cc48bbdcd41af52ec9;p=php Deal with overflow when decoding large numbers --- diff --git a/ext/json/JSON_parser.c b/ext/json/JSON_parser.c index ec874a7ec2..f00b5d4c01 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 TSRMLS_DC) 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); }