]> granicus.if.org Git - php/commitdiff
MFH Deal with overflow when decoding large numbers
authorScott MacVicar <scottmac@php.net>
Tue, 17 Mar 2009 14:57:39 +0000 (14:57 +0000)
committerScott MacVicar <scottmac@php.net>
Tue, 17 Mar 2009 14:57:39 +0000 (14:57 +0000)
ext/json/JSON_parser.c

index 8eaf65e85c2fba61dbd3ce9b2885cbc2e7ed42bf..71250126106ef2f55f4768115ae4698b5678b43e 100644 (file)
@@ -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);
                }