From 3a0c86327f891a3d150bc8165d5ec86d09bc94a8 Mon Sep 17 00:00:00 2001 From: Scott MacVicar Date: Tue, 17 Mar 2009 14:57:39 +0000 Subject: MFH Deal with overflow when decoding large numbers --- ext/json/JSON_parser.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ext/json/JSON_parser.c') 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); } -- cgit v1.2.1